home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / asa / readme.ms < prev    next >
Text File  |  1994-10-23  |  82KB  |  2,534 lines

  1. .\" To avoid creating an extra macro file just for the references,
  2. .\" some macros are inserted here to obtain some minimal formatting.
  3. .\"
  4. .ie \n(.g \{\
  5. .\"        Some macros used in geqn
  6. .if t .char { \fS{
  7. .if t .char } \fS}
  8. .\"         Some grefer macro changes
  9. .hlm 0
  10. .de R1
  11. .ig R2
  12. ..
  13. .R1
  14. accumulate
  15. no-default-database
  16. move-punctuation
  17. bracket-label [ ] ","
  18. sort-adjacent-labels
  19. .R2
  20. .de ]<
  21. .als ref*print ref*end-print
  22. .NH 1
  23. References
  24. .XS
  25. \\*(SN     References
  26. .XE
  27. .par@reset
  28. ..
  29. .de ref*end-print
  30. .ie d [F .IP "[\\*([F]"
  31. .el .XP
  32. \\*[ref*string]
  33. ..
  34. .\}
  35. .el \{\
  36. .\"          Some refer macro changes
  37. .ds [. [
  38. .ds .] ]
  39. .de ]<
  40. .NH 1
  41. References
  42. .XS
  43. \\*(SN     References
  44. .XE
  45. .LP
  46. .de FP
  47. .IP "[\\\\$1]"
  48. \\..
  49. .rm FS FE
  50. ..
  51. .\}
  52. .\"        Header formatting
  53. .ds LF
  54. .ds CF
  55. .ds RF
  56. .ds LH Adaptive Simulated Annealing (ASA)
  57. .ds CH
  58. .ds RH Lester Ingber
  59. .nr PO 1i
  60. .nr LL 6.5i
  61. .ll 6.5i
  62. .nr LT 6.5i
  63. .lt 6.5i
  64. .nr PS 11
  65. .nr VS 12
  66. .\"        Text
  67. .SH
  68. .ce
  69. ADAPTIVE SIMULATED ANNEALING (ASA) \(co
  70. .LP
  71. .ce 99
  72. .sp
  73. .sp
  74. Lester Ingber
  75. .sp
  76. Lester Ingber Research
  77. P.O. Box 857
  78. McLean, VA 22101
  79. .sp
  80. ingber@alumni.caltech.edu
  81. .ce 0
  82. .pn 1
  83. .P1
  84. .bp
  85. .ds CF - \\n(PN -
  86. .af PN 1
  87. .NH 1
  88. GNU General Public License (GPL)
  89. .XS
  90. \*(SN     GNU General Public License (GPL)
  91. .XE
  92. .PP
  93. This Adaptive Simulated Annealing (ASA) code is being made available
  94. under a GNU COPYING \*Qcopyleft\*U license, and is owned by Lester
  95. Ingber.
  96. .[
  97. %A L. Ingber
  98. %R [ftp.alumni.caltech.edu: /pub/ingber/ASA\-shar, ASA\-shar.Z, ASA.tar.Z, ASA.tar.gz, ASA.zip]
  99. %I Lester Ingber Research
  100. %C McLean, VA
  101. %T Adaptive Simulated Annealing (ASA)
  102. %D 1993
  103. .]
  104. Please read the copy of this license contained in this directory.  Its
  105. intent is to make this code publicly available to the widest audience
  106. while maintaining the integrity of the basic algorithm.
  107. .NH 1
  108. Documentation
  109. .XS
  110. \*(SN     Documentation
  111. .XE
  112. .LP
  113. .NH 2
  114. Table of Contents
  115. .XS
  116. \*(SN         Table of Contents
  117. .XE
  118. .PP
  119. A Table of Contents of the three levels of headers with their page
  120. numbers is located at the end of this document.  This may be placed
  121. after the first title page, or left at the end for quick reference.
  122. .NH 2
  123. readme.ms
  124. .XS
  125. \*(SN         readme.ms
  126. .XE
  127. .PP
  128. The readme.ms file is used to prepare other documentation files using
  129. UNIX\(rg MS macros.
  130. .NH 2
  131. README and README+
  132. .XS
  133. \*(SN         README and README+
  134. .XE
  135. .PP
  136. README is an ASCII file that can be previewed on your screen or sent
  137. to an ASCII lineprinter.
  138. .PP
  139. README+ is README without any filters to strip off underlining and bold
  140. enhancements.  This is uuencoded to the file README+.uu in order to
  141. pass through the shar utility.  If you have downloaded ASA-shar or
  142. ASA-shar.Z, to use this file, `uudecode README+.uu` will leave
  143. README+.
  144. .NH 2
  145. asa.[13nl] Manpage
  146. .XS
  147. \*(SN         asa.[13nl] Manpage
  148. .XE
  149. .PP
  150. The README or README+ file can be copied to a file named asa.[l3], and
  151. asa.[13] can be installed as MANPATH/cat1/asa.1 or MANPATH/cat3/asa.3,
  152. where MANPATH is the place your man directory is located.  If you do
  153. not have any cat[13] directories on your system, then installing a copy
  154. of README or README+ as MANPATH/man[13nl]/asa.[13nl], choosing one of
  155. the suffixes in [13nl] for your choice of directory and asa file name,
  156. should work fine on most machines.  (However, passing asa.[13nl] which
  157. is the equivalent of README[+] through man may strip out some items
  158. like \\"asa_out\\".)  You likely can avoid some further undesirable
  159. formatting by man by placing '.nf' on the first line of this file.
  160. .NH 2
  161. README.ps
  162. .XS
  163. \*(SN         README.ps
  164. .XE
  165. .PP
  166. README.ps is a PostScript\(rg formatted file which may be previewed on
  167. your screen if you have the proper software, or it may be sent to a
  168. PostScript\(rg printer to produce hardcopy.
  169. .NH 2
  170. Additional Documentation
  171. .XS
  172. \*(SN         Additional Documentation
  173. .XE
  174. .PP
  175. CHANGES is a terse record of major changes made in the ASA code.  NOTES
  176. is a collection of recommended enhancements, modifications, comments,
  177. caveats, etc., that might be of interest.
  178. .PP
  179. The file asa_new in ftp.alumni.caltech.edu: /pub/ingber is a list of
  180. major changes in ASA since the last announcement to the ASA_list.  This
  181. can be used as a quick guide to determine if you should download the
  182. latest ASA code in the archive before the next announcement.
  183. .PP
  184. An addendum to NOTES is the file asa_papers in ftp.alumni.caltech.edu:
  185. /pub/ingber, listing some (p)reprints that have used ASA or its
  186. precursor VFSR.  This separation of information is to minimize updating
  187. versions of the ASA directory due to changes in this section.
  188. .PP
  189. It is certain that there is much research to be done on determining
  190. optimal or even reasonable ASA parameters, e.g., the set of Program
  191. Options, for different classes of systems, especially in higher
  192. dimensional spaces of user parameters.  (In the NOTES file are some
  193. comments on how you might use ASA recursively to determine the optimal
  194. set of some Program Options for a given system.)  A major purpose of
  195. making this code publicly available is to motivate more of this
  196. research, and thus make the code more useful to a wider audience.
  197. .NH 2
  198. Parallelizing ASA and PATHINT Project (PAPP)
  199. .XS
  200. \*(SN         Parallelizing ASA and PATHINT Project (PAPP)
  201. .XE
  202. .PP
  203. The file /pub/ingber/MISC.DIR/parallel.txt contains an update of the
  204. Parallelizing ASA and PATHINT Project (PAPP).  No code will be released
  205. until it has passed some reasonable tests and has reasonable
  206. documentation.
  207. .NH 2
  208. Additional Information
  209. .XS
  210. \*(SN         Additional Information
  211. .XE
  212. .PP
  213. Sorry, I cannot assume the task of mailing out hardcopies of code or
  214. papers.   My volunteer time assisting people with their queries on my
  215. codes and papers must be limited to electronic mail correspondence.
  216. Commercial consulting appointments can be made by contacting me via
  217. e-mail, mail, or calling 1.800.L.INGBER.
  218. .NH 1
  219. Availability of ASA Code
  220. .XS
  221. \*(SN     Availability of ASA Code
  222. .XE
  223. .LP
  224. .NH 2
  225. Caltech
  226. .XS
  227. \*(SN         Caltech
  228. .XE
  229. .PP
  230. The latest Adaptive Simulated Annealing (ASA) code and some related
  231. (p)reprints can be retrieved via anonymous ftp from
  232. ftp.alumni.caltech.edu [131.215.139.234] in the /pub/ingber directory.
  233. This archive also can be accessed via WWW path
  234. http://alumni.caltech.edu/~ingber/ or
  235. ftp://ftp.alumni.caltech.edu/pub/ingber/.
  236. .KS
  237. .PP
  238. Interactively [brackets signify machine prompts]:
  239. .in +8n
  240. .nf
  241. [your_machine%] ftp ftp.alumni.caltech.edu
  242. [Name (...):] anonymous
  243. [Password:] your_e\-mail_address
  244. [ftp>] cd pub/ingber
  245. [ftp>] binary
  246. [ftp>] ls
  247. [ftp>] get file_of_interest
  248. [ftp>] quit
  249. .fi
  250. .in 0
  251. The 00index file contains an index of the other files and information
  252. on getting gzip and unshar for DOS\(rg, MAC\(rg, UNIX\(rg, and VMS\(rg
  253. systems.
  254. .KE
  255. .PP
  256. The latest version of ASA, ASA\-x.y (x and y are version numbers), can
  257. be obtained in several formats.  ASA\-shar.Z is a compress'd shar'd
  258. file of the current code.  For the convenience of users who do not have
  259. any uncompress/gunzip utility, there is a file ASA\-shar which is an
  260. uncompress'd copy of ASA\-shar.Z; if you do not have sh or shar, you
  261. still can delete the first\-column X's and separate the files at the
  262. END_OF_FILE locations.  There are tar'd versions in compress and gzip
  263. format, ASA.tar.Z and ASA.tar.gz, respectively.  There also is a
  264. current zip'd version, ASA.zip, in which all files have been processed
  265. through unix2dos.  Directory /pub/ingber/0lower.dir contains links to
  266. these files for some PC users who may have difficulty with upper case.
  267. .PP
  268. Patches ASA\-diff\-x1.y1\-x2.y2.Z up to the present version can be
  269. prepared, if a good case for doing so is presented.  These may be
  270. concatenated as required before applying.  If you require a specific
  271. patch that is not contained in the archive, contact
  272. ingber@alumni.caltech.edu.
  273. .NH 2
  274. Electronic Mail
  275. .XS
  276. \*(SN         Electronic Mail
  277. .XE
  278. .PP
  279. If you do not have ftp access, get information on the FTPmail service
  280. by: mail ftpmail@decwrl.dec.com, and send only the word \*Qhelp\*U as
  281. the body of the message.  You will receive the information in
  282. /pub/ingber/UTILS.DIR/ftpmail.txt.  Similarly, from a BITNET site, send
  283. the word \*Qhelp\*U as the body of a message to bitftp@pucc
  284. (bitftp@pucc.bitnet if from an Internet site).
  285. .PP
  286. If any of the above are not possible, and if your mailer can handle
  287. large files (please test this first), the code or papers you require
  288. can be sent as uuencode'd compress'd files via electronic mail.  If you
  289. have gzip, resulting in smaller files, please state this.
  290. .NH 2
  291. ASA Mailing List
  292. .XS
  293. \*(SN         ASA Mailing List
  294. .XE
  295. .PP
  296. If you wish to be placed on the electronic mailing ASA_list to receive
  297. major updates between public announcements of new versions, please send
  298. e\-mail stating this request to asa\-request@alumni.caltech.edu.
  299. Update notices are sent to the ASA_list about every month or two, more
  300. frequently if warranted, e.g., in cases of important bug fixes; these
  301. notices are the only e\-mail sent to the ASA_list.  This is highly
  302. recommended if you plan to use ASA on complex systems, as there is
  303. ongoing research using and testing ASA by many users.  To unsubscribe
  304. from this list, simply send an electronic mail with this request to
  305. asa\-request@alumni.caltech.edu.
  306. .NH 1
  307. Background
  308. .XS
  309. \*(SN     Background
  310. .XE
  311. .LP
  312. .NH 2
  313. Context
  314. .XS
  315. \*(SN         Context
  316. .XE
  317. .PP
  318. The ASA code was first developed in 1987 as Very Fast Simulated
  319. Reannealing (VFSR) to deal with the necessity of performing adaptive
  320. global optimization on multivariate nonlinear stochastic systems.
  321. .[
  322. %A L. Ingber
  323. %T Very fast simulated re-annealing
  324. %J Mathl. Comput. Modelling
  325. %V 12
  326. %P 967-973
  327. %D 1989
  328. .]
  329. VFSR was recoded and applied to several complex systems, in combat
  330. analysis,
  331. .[
  332. %A L. Ingber
  333. %A H. Fujio
  334. %A M.F. Wehner
  335. %T Mathematical comparison of combat computer models to exercise data
  336. %J Mathl. Comput. Modelling
  337. %V 15
  338. %P 65-90
  339. %D 1991
  340. .]
  341. finance,
  342. .[
  343. %A L. Ingber
  344. %T Statistical mechanical aids to calculating term structure models
  345. %J Phys. Rev. A
  346. %V 42
  347. %D 1990
  348. %P 7057-7064
  349. .]
  350. and neuroscience.
  351. .[
  352. %A L. Ingber
  353. %T Statistical mechanics of neocortical interactions:
  354. A scaling paradigm applied to electroencephalography
  355. %J Phys. Rev. A
  356. %V 44
  357. %P 4017-4060
  358. %D 1991
  359. .]
  360. The first applications to combat analysis used code written in RATFOR
  361. and converted into FORTRAN.  Other applications since then have used
  362. new code written in C.  (The NOTES file contains some comments on
  363. interfacing ASA with FORTRAN codes.)  A paper has indicated how this
  364. technique can be enhanced by combining it with some other powerful
  365. algorithms, e.g., to produce an algorithm for parallel computation.
  366. .[
  367. %A L. Ingber
  368. %T Generic mesoscopic neural networks based on statistical mechanics
  369. of neocortical interactions
  370. %J Phys. Rev. A
  371. %V 45
  372. %P R2183-R2186
  373. %D 1992
  374. .]
  375. In November 1992, the VFSR C-code was rewritten, e.g., changing to the
  376. use of long descriptive names, and made publicly available as version
  377. 6.35 under the same GNU license as this ASA code.
  378. .[
  379. %A L. Ingber
  380. %A B. Rosen
  381. %R [ringer.cs.utsa.edu: /pub/rosen/vfsr.Z]
  382. %I University of Texas
  383. %C San Antonio, TX
  384. %T Very Fast Simulated Reannealing (VFSR)
  385. %D 1992
  386. .]
  387. .PP
  388. Beginning in January 93, many adaptive features were developed, largely
  389. in response to users' requests, leading to this ASA code.  ASA has been
  390. examined in the context of a review of methods of simulated annealing
  391. using annealing versus quenching (faster temperature schedules than
  392. permitted by basic heuristic proof of ergodicity).
  393. .[
  394. %A L. Ingber
  395. %T Simulated annealing: Practice versus theory
  396. %J Mathl. Comput. Modelling
  397. %V 18
  398. %D 1993
  399. %P 29-57
  400. .]
  401. ASA is now used world-wide across many disciplines.
  402. .[
  403. %A M. Wofsey
  404. %T Technology: Shortcut tests validity of complicated formulas
  405. %J The Wall Street Journal
  406. %V CCXXII
  407. %P B1
  408. %D 24 September 1993
  409. .]
  410. .\"        Equations set only in PostScript\(rg ([g]troff)
  411. .if t \{\
  412. .EQ
  413. delim $$
  414. gsize 11
  415. .EN
  416. .\}
  417. .NH 2
  418. Outline of ASA Algorithm
  419. .XS
  420. \*(SN         Outline of ASA Algorithm
  421. .XE
  422. .PP
  423. Details of the ASA algorithm are best obtained from the published
  424. papers.  There are three parts to its basic structure.
  425. .NH 3
  426. Generating Probability Density Function
  427. .XS
  428. \*(SN             Generating Probability Density Function
  429. .XE
  430. .PP
  431. In a
  432. .if t $D$-dimensional
  433. .if n D-dimensional
  434. parameter space with parameters
  435. .if t $p sup i$
  436. .if n p^i
  437. having ranges
  438. .if t $[ A sub i ,~ B sub i ]$,
  439. .if n [A_i, B_i],
  440. about the
  441. .if t $k$'th
  442. .if n k'th
  443. last saved point (e.g, a local optima),
  444. .if t $p sub k sup i$,
  445. .if n p_k^i,
  446. a new point is generated using a distribution defined by the product
  447. of distributions for each parameter,
  448. .if t $g sup i ( y sup i ;^ T sub i )$
  449. .if n g^i(y^i; T_i),
  450. in terms of random variables
  451. .if t $y sup i \(mo [ -1 ,~ 1]$,
  452. .if n y^i in [-1, 1],
  453. where
  454. .if t $p sub k+1 sup i$ = $p sub k sup i + y sup i ( B sub i - A sub i )$,
  455. .if n p_k+1^i = p_k^i + y^i(B_i - A_i),
  456. and \*Qtemperatures\*U
  457. .if t $T sub i$,
  458. .if n T_i,
  459. .ie t \{\
  460. .EQ I
  461. g sup i ( y sup i ;^ T sub i ) = 1 over { 2 ( | y sup i | + T sub i )
  462. ln ( 1 + 1 / T sub i ) } ~.
  463. .EN
  464. .\}
  465. .el \{\
  466. .in +8n
  467. g^i(y^i; T_i) = 1/[2(|y^i| + T_i)(1 + 1/T_i)].
  468. .in 0
  469. .\}
  470. .NH 3
  471. Acceptance Probability Density Function
  472. .XS
  473. \*(SN             Acceptance Probability Density Function
  474. .XE
  475. .PP
  476. The cost functions,
  477. .if t $C ( p sub k+1 ) - C ( p sub k )$,
  478. .if n C(p_k+1) - C(p_k),
  479. are compared using a uniform random generator,
  480. .if t $U \(mo [ 0 ,~ 1 )$,
  481. .if n U in [0, 1),
  482. in a \*QBoltzmann\*U test: If
  483. .ie t \{\
  484. .EQ I
  485. exp [ - fat ( C (p sub k+1 )  - C ( p sub k ) fat ) /
  486. T sub {roman cost} ] > U ~,
  487. .EN
  488. .\}
  489. .el \{\
  490. .in +8n
  491. exp[-(C(p_k+1) - C(p_k))/T_cost] > U,
  492. .in 0
  493. .\}
  494. where
  495. .if t $T sub {roman cost}$
  496. .if n T_cost
  497. is the \*Qtemperature\*U used for this test, then the new point is
  498. accepted as the new saved point for the next iteration.  Otherwise, the
  499. last saved point is retained.
  500. .NH 3
  501. Reannealing Temperature Schedule
  502. .XS
  503. \*(SN             Reannealing Temperature Schedule
  504. .XE
  505. .PP
  506. The annealing schedule for each parameter temperature,
  507. .if t $T sub i$
  508. .if n T_i,
  509. from a starting temperature
  510. .if t $T sub i0$,
  511. .if n T_i0,
  512. is
  513. .ie t \{\
  514. .EQ I
  515. T sub i ( k sub i ) = T sub 0i exp ( - c sub i k sub i sup 1/D ) ~.
  516. .EN
  517. .\}
  518. .el \{\
  519. .in +8n
  520. T_i(k_i) = T_0i exp(-c_i k_i^(1/D)).
  521. .in 0
  522. .\}
  523. This is discussed further below.
  524. .PP
  525. The annealing schedule for the cost temperature is developed similarly
  526. to the parameter temperatures.  However, the index for reannealing the
  527. cost function,
  528. .if t $k sub {roman cost}$,
  529. .if n k_cost,
  530. is determined by the number of accepted points, instead of the number
  531. of generated points as used for the parameters.  This choice was made
  532. because the Boltzmann acceptance criteria uses an exponential
  533. distribution which is not as fat-tailed as the ASA distribution used
  534. for the parameters.  This schedule can be modified using several
  535. OPTIONS.  In particular, the Pre-Compile DEFINE_OPTIONS
  536. USER_COST_SCHEDULE permits quite arbitrary functional modifications for
  537. this annealing schedule.
  538. .PP
  539. As determined by the Program Options selected, the parameter
  540. \*Qtemperatures\*U may be periodically adaptively reannealed, or
  541. increased relative to their previous values, using their relative first
  542. derivatives with respect to the cost function, to guide the search
  543. \*Qfairly\*U among the parameters.
  544. .NH 2
  545. Efficiency Versus Necessity
  546. .XS
  547. \*(SN         Efficiency Versus Necessity
  548. .XE
  549. .PP
  550. ASA is not necessarily an \*Qefficient\*U code.  For example, if you
  551. know that your cost function to be optimized is something close to a
  552. parabola, then a simple gradient Newton search method most likely would
  553. be faster than ASA.  ASA is believed to be faster and more robust than
  554. other simulated annealing techniques for \f2most\f1 complex problems
  555. with multiple local optima; again, be careful to note that some
  556. problems are best treated by other algorithms.  If you do not know much
  557. about the structure of your system, and especially if it has complex
  558. constraints, and you need to search for a global optimum, then this ASA
  559. code is heartily recommended to you.
  560. .NH 1
  561. Outline of Use
  562. .XS
  563. \*(SN     Outline of Use
  564. .XE
  565. .PP
  566. Set up the ASA interface: Your program should be divided into two basic
  567. modules.  (1) The user calling procedure, containing the cost function
  568. to be minimized (or its negative if you require a global maximum), here
  569. is contained in user.c and user.h.  (2) The ASA optimization procedure,
  570. here is contained in asa.c and asa.h.  The file asa_user.h contains
  571. definitions and macros common to both asa.h and user.h.  Furthermore,
  572. there are some options to explore/read below.  It is assumed there will
  573. be no confusion over the standard uses of the term \*Qparameter\*U in
  574. different contexts, e.g., as an element passed by a subroutine or as a
  575. physical coefficient in a cost function.
  576. .PP
  577. ASA has been run successfully on many machines under many compilers.
  578. To check out your own system, you can run `make` (or the equivalent set
  579. of commands in the Makefile), and compare your asa_out and user_out
  580. files to the test_asa and test_usr files, respectively, provided with
  581. this code.  (For these runs, TIME_CALC=TRUE, discussed below, was added
  582. to the compilation options.)  No attempt was made to optimize any
  583. compiler, so that the test runs do not really signify any testing of
  584. compilers or architectures; rather they are meant to be used as a guide
  585. to determine what you might expect on your own machine.
  586. .PP
  587. The major sections below describe the compilation procedures, the
  588. Program Options available to you to control the code, the use of
  589. templates to set up your user module and interface to the asa module,
  590. and how to submit bug reports.
  591. .PP
  592. If you already have your own cost function defined, as a quick guide to
  593. get started, you can search through user.c for all occurrences of
  594. \*QMY_COST\*U to insert the necessary definitions required to run ASA.
  595. .NH 1
  596. Makefile/Compilation Procedures
  597. .XS
  598. \*(SN     Makefile/Compilation Procedures
  599. .XE
  600. .PP
  601. The PostScript\(rg README.ps and ASCII README and README+ files were
  602. generated using `make doc'.  The Makefile describes some options for
  603. formatting these files differently.  Use `make' or `make all' to
  604. compile and run asa_run, the executable prepared for the test
  605. function.  Examine the Makefile to determine the \*Qclean\*U options
  606. available.
  607. .PP
  608. Since complex problems by their nature are often quite unique, it is
  609. unlikely that the default parameters are just right for your problem.
  610. However, experience has shown that if you \f2a priori\f1 do not have
  611. any reason to determine your own parameters, then you might do just
  612. fine using these defaults, and these are recommended as a first-order
  613. guess.  These defaults can be changed simply by adding to the
  614. DEFINE_OPTIONS line in the Makefile, by passing options on your command
  615. line, and by changing structure elements in the user or asa module as
  616. described below.  Depending on how you integrate ASA into your own user
  617. modules, you may wish to modify this Makefile or at least use some of
  618. these options in your own compilation procedures.
  619. .PP
  620. Note that the Makefile is just a convenience, not a necessity, to use
  621. ASA.  E.g., on systems which do not support this utility, you may
  622. simply compile the files following the guidelines in the Makefile,
  623. taking care to pass the correct DEFINE_OPTIONS to your compilation
  624. commands at your shell prompt.  Still another way, albeit not as
  625. convenient, is to make the desired changes in the asa_user.h, and asa.h
  626. or user.h files as required.
  627. .PP
  628. Since the Makefile contains comments giving short descriptions of some
  629. options, it should be considered as an extension of this documentation
  630. file.  For convenience, most of this information is repeated below.
  631. However, to see how they can be used in compilations, please read
  632. through the Makefile.
  633. .PP
  634. For example, to run the ASA test problem using the gcc compiler, you
  635. could just type at your \*Q%\*U prompt:
  636. .nf
  637. .in +8n
  638. % gcc -g -DASA_TEST=TRUE -o asa_run user.c asa.c -lm
  639. % asa_run
  640. .in 0
  641. .fi
  642. You may have to feed different options to your own compiler.  The
  643. resulting asa_out file should only differ from the test_asa file by
  644. having different values for the OPTIONS_FILE and TIME_CALC lines, and
  645. by not having a few lines marking the CPU time.
  646. .PP
  647. If you have defined your own cost function within the \*QMY_COST\*U
  648. guides in user.c, then ASA_TEST should be set to FALSE (the default if
  649. ASA_TEST is not defined in your compilation lines or in the Makefile).
  650. The code for ASA_TEST=TRUE is given just above these guides as a
  651. template to use for your own cost function.
  652. .NH 1
  653. User Options
  654. .XS
  655. \*(SN     User Options
  656. .XE
  657. .PP
  658. The DEFINE_OPTIONS are organized into two groups: Pre-Compile Options
  659. and (Pre-Compile) Printing Options.  In addition, there are some
  660. alternatives to explore under Compiler Choices and Document
  661. Formatting.  Below are the DEFINE_OPTIONS with their defaults.  The
  662. Program Options are further discussed in other sections in this
  663. document.
  664. .NH 2
  665. Pre-Compile DEFINE_OPTIONS
  666. .XS
  667. \*(SN         Pre-Compile DEFINE_OPTIONS
  668. .XE
  669. .LP
  670. .NH 3
  671. OPTIONS_FILE=TRUE
  672. .XS
  673. \*(SN             OPTIONS_FILE=TRUE
  674. .XE
  675. .PP
  676. You can elect to read in the Program Options from asa_opt by setting
  677. OPTIONS_FILE=TRUE.  OPTIONS_FILE=TRUE can be set in the Makefile in
  678. compilation commands or in asa_user.h.
  679. .NH 3
  680. ASA_LIB=FALSE
  681. .XS
  682. \*(SN             ASA_LIB=FALSE
  683. .XE
  684. .PP
  685. Setting ASA_LIB=TRUE will facilitate your running asa() as a library
  686. call from another program, calling asa_main() in user.c.  In the
  687. templates provided, all initializations and cost function definitions
  688. are set up in user.c.  For example, you may wish to have some data read
  689. in to a module that calls asa_main(), then parses out this information
  690. to the arrays in asa_main() and initialize_parameters (and possibly
  691. recur_initialize_parameters).  In conjunction with setting printout to
  692. stdout (see ASA_OUT and USER_ASA_OUT), this can be a convenient way of
  693. using the same asa_run executable for many runs.
  694. .NH 3
  695. HAVE_ANSI=TRUE
  696. .XS
  697. \*(SN             HAVE_ANSI=TRUE
  698. .XE
  699. .PP
  700. Setting HAVE_ANSI=FALSE will permit you to use an older K&R C
  701. compiler.  This option can be used if you do not have an ANSI compiler,
  702. overriding the default HAVE_ANSI=TRUE.  If you use HAVE_ANSI=FALSE,
  703. change CC and CDEBUGFLAGS as described in the Makefile.
  704. .NH 3
  705. IO_PROTOTYPES=TRUE
  706. .XS
  707. \*(SN             IO_PROTOTYPES=TRUE
  708. .XE
  709. .PP
  710. Some machines do not like any other I/O prototyping other than those in
  711. their own include files, e.g., like one Convex-120 that was tested.
  712. Other machines, like a Dec-3100 under Ultrix complained that the ANSI
  713. I/O prototypes were inconsistent.  A Sun under gcc gave warnings if no
  714. I/O prototypes were present.  Therefore, the defaults in asa_user.h use
  715. K&R system prototypes even for the ANSI compiler, for fprintf, fflush,
  716. fclose, and exit, and for fscanf in user.h.  Setting
  717. IO_PROTOTYPES=FALSE will comment out even these declarations.  This
  718. also has worked on an Indigo and on a Cray C90/UNICOS 8.0.
  719. .NH 3
  720. TIME_CALC=FALSE
  721. .XS
  722. \*(SN             TIME_CALC=FALSE
  723. .XE
  724. .PP
  725. Some systems do not have the time include files used here; others have
  726. different scales for time.  Setting TIME_CALC=TRUE will permit use of
  727. the time routines.  In the NOTES are some contributed code that should
  728. be useful for some particular systems.
  729. .NH 3
  730. TIME_STD=FALSE
  731. .XS
  732. \*(SN             TIME_STD=FALSE
  733. .XE
  734. .PP
  735. Some systems, e.g., hpux, use other Unix-standard macros to access
  736. time.  Setting TIME_STD=TRUE when using TIME_CALC=TRUE will use these
  737. time routines instead.
  738. .NH 3 
  739. INT_LONG=TRUE
  740. .XS
  741. \*(SN             INT_LONG=TRUE
  742. .XE
  743. .PP
  744. Some smaller systems choke on `long int' and this option can be set to
  745. INT_LONG=FALSE to turn off warnings and possibly some errors.  The cast
  746. LONG_INT is used to define `int' or `long int' appropriately.
  747. .NH 3
  748. INT_ALLOC=FALSE
  749. .XS
  750. \*(SN             INT_ALLOC=FALSE
  751. .XE
  752. .PP
  753. The cast on *number_parameters is set to ALLOC_INT which defaults to
  754. LONG_INT.  On some machines, ALLOC_INT might have to be set to int if
  755. there is a strict requirement to use an (unsigned) int for calloc,
  756. while `long int' still can be used for other aspects of ASA.  If
  757. ALLOC_INT is to be set to int, set INT_ALLOC to TRUE.
  758. .NH 3
  759. SMALL_FLOAT=1.0E-18
  760. .XS
  761. \*(SN             SMALL_FLOAT=1.0E-18
  762. .XE
  763. .PP
  764. SMALL_FLOAT is a measure of accuracy permitted in log and divide
  765. operations in asa, i.e., which is not precisely equivalent to a given
  766. machine's precision.  There also are Pre-Compile DEFINE_OPTIONS to
  767. separately set constants for minimum and maximum doubles and precision
  768. permitted by your machine.  Experts who require the very best precision
  769. can fine-tune these parameters in the code.
  770. .PP
  771. Such issues arise because the fat tail of ASA, associated with high
  772. parameter temperatures, is very important for searching the breadth of
  773. the ranges especially in the initial stages of search.  However, the
  774. parameter temperatures require small values at the final stages of the
  775. search to converge to the best solution, albeit this is reached very
  776. quickly given the exponential schedule proven in the referenced
  777. publications to be permissible with ASA.  Note that the test problem in
  778. user.c is a particularly nasty one, with 1E20 local minima and
  779. requiring ASA to search over 12 orders of magnitude of the cost
  780. function before correctly finding the global minimum.  Thus,
  781. intermediate values disagree somewhat for SMALL_FLOAT=1.0E-12 from the
  782. settings using SMALL_FLOAT=1.0E-18 (the default);  they agree if
  783. SMALL_FLOAT=1.0E-12 while also setting MIN_DOUBLE=1.0E-18.  The results
  784. diverge when the parameter temperatures get down to the range of E-12,
  785. limiting the accuracy of the SMALL_FLOAT=1.0E-12 run.
  786. .NH 3
  787. MIN_DOUBLE=SMALL_FLOAT
  788. .XS
  789. \*(SN             MIN_DOUBLE=SMALL_FLOAT
  790. .XE
  791. .PP
  792. You can define your own machine's minimum positive double here if you
  793. know it.
  794. .NH 3
  795. MAX_DOUBLE=1.0/SMALL_FLOAT
  796. .XS
  797. \*(SN             MAX_DOUBLE=1.0/SMALL_FLOAT
  798. .XE
  799. .PP
  800. You can define your own machine's maximum double here if you know it.
  801. .NH 3
  802. EPS_DOUBLE=SMALL_FLOAT
  803. .XS
  804. \*(SN             EPS_DOUBLE=SMALL_FLOAT
  805. .XE
  806. .PP
  807. You can define your own machine's maximum precision here if you know
  808. it.
  809. .NH 3
  810. NO_PARAM_TEMP_TEST=FALSE
  811. .XS
  812. \*(SN             NO_PARAM_TEMP_TEST=FALSE
  813. .XE
  814. .PP
  815. If NO_PARAM_TEMP_TEST is set to TRUE, then all parameter temperatures
  816. less than EPS_DOUBLE are set to EPS_DOUBLE, and no exit is called.
  817. .NH 3
  818. NO_COST_TEMP_TEST=FALSE
  819. .XS
  820. \*(SN             NO_COST_TEMP_TEST=FALSE
  821. .XE
  822. .PP
  823. If NO_COST_TEMP_TEST is set to TRUE, then a cost temperature less than
  824. EPS_DOUBLE is set to EPS_DOUBLE, and no exit is called.
  825. .NH 3
  826. SELF_OPTIMIZE=FALSE
  827. .XS
  828. \*(SN             SELF_OPTIMIZE=FALSE
  829. .XE
  830. .PP
  831. The user module contains a template to illustrate how ASA may be used
  832. to self-optimize its Program Options.  This can be very CPU-expensive
  833. and is of course dependent on how you define your recursive cost
  834. function (recur_cost_function in the user module).  The example given
  835. returns from recur_cost_function the number of function evaluations
  836. taken to optimization the test cost_function, with the constraint to
  837. only accept optimizations of the cost_function that are lower than a
  838. specified value.  A few lines of code can be uncommented in user.c to
  839. force a fast exit for this demo; search for FAST EXIT.  This example
  840. uses OPTIONS_FILE=FALSE (the default) in the Pre-Compile Options; note
  841. that OPTIONS_FILE=TRUE here would set Program Options from asa_opt for
  842. the top level program, not for the Program Options for the
  843. cost_function().
  844. .PP
  845. This can be useful when approaching a new system, and it is suspected
  846. that the default ASA Program Options are not at all efficient for this
  847. system.  It is suggested that a trimmed cost function or data set be
  848. used to get a reasonable guess for a good set of Program Options.  ASA
  849. has demonstrated that it typically is quite robust under a given set of
  850. Program Options, so it might not make too much sense to spend lots of
  851. resources performing additional fine tuning of the these options.
  852. Also, it is possible you might crash the code by permitting ranges of
  853. Program Options that cause your particular cost_function to return
  854. garbage to asa().
  855. .NH 3
  856. ASA_TEST=FALSE
  857. .XS
  858. \*(SN             ASA_TEST=FALSE
  859. .XE
  860. .PP
  861. Setting ASA_TEST to TRUE will permit running the ASA test problem.
  862. This has been added to the DEFINE_OPTIONS in the Makefile so that just
  863. running make will run the test problem for the new user.
  864. .PP
  865. Searching user.c for \*QMY_COST\*U provides a guide to the user for
  866. additional code to add for his/her own system.  Just above each
  867. occurrence of these guides is the corresponding code for ASA_TEST=TRUE.
  868. Keeping the default of ASA_TEST set to FALSE permits such changes
  869. without overwriting the test example.
  870. .NH 3
  871. ASA_TEMPLATE=FALSE
  872. .XS
  873. \*(SN             ASA_TEMPLATE=FALSE
  874. .XE
  875. .PP
  876. There are several templates that come with the ASA code, used to test
  877. several OPTIONS.  To permit use of these OPTIONS without having to
  878. delete these extra tests, these templates are wrapped with
  879. ASA_TEMPLATE.  To use tests associated with these OPTIONS, which can be
  880. determined by reading the code, just set ASA_TEMPLATE to TRUE in the
  881. Makefile or in your compilation procedures.
  882. .PP
  883. Note that running the ASA test problem in user.c is not affected by
  884. ASA_TEMPLATE.  To use your own cost function, you must at least rewrite
  885. relevant portions of cost_function() and initialize_parameters() in
  886. user.c.
  887. .NH 3
  888. OPTIONAL_DATA=FALSE
  889. .XS
  890. \*(SN             OPTIONAL_DATA=FALSE
  891. .XE
  892. .PP
  893. It can be useful to return additional information to the user module
  894. from the asa module.  When OPTIONAL_DATA is set to true, an additional
  895. Program Option pointer, *asa_data,  is available in USER_DEFINES
  896. *OPTIONS to gather such data.
  897. .PP
  898. In one ASA_TEMPLATE provided (see the set of DEFINE_OPTIONS used in the
  899. Makefile), OPTIONAL_DATA is used together with SELF_OPTIMIZE to find
  900. the set of ASA parameters giving the (statistically) smallest number of
  901. generated points to solve the ASA test problem, assuming this were run
  902. several times with different random seeds for randflt in user.c (e.g.,
  903. changing \*Qseed\*U in myrand).  Here, asa_data[0] is used as a flag to
  904. print out asa_data[1] in user.c, set to *best_number_generated_saved in
  905. asa.c.
  906. .NH 3
  907. USER_COST_SCHEDULE=FALSE
  908. .XS
  909. \*(SN             USER_COST_SCHEDULE=FALSE
  910. .XE
  911. .PP
  912. The function used to control the cost_function temperature schedule is
  913. of the form test_temperature in asa.c.  If the user sets the
  914. Pre-Compile DEFINE_OPTIONS USER_COST_SCHEDULE to TRUE, then this
  915. function of test_temperature can be controlled, adaptively if desired,
  916. in user.c in cost_schedule() (and in recur_cost_schedule() if
  917. SELF_OPTIMIZE is TRUE) by setting USER_COST_SCHEDULE to TRUE.  The
  918. names of these functions are set to the relevant pointer in user.c, and
  919. can be changed if desired, i.e.,
  920. .in +3n
  921. USER_OPTIONS->cost_schedule = user_cost_schedule;
  922. .br
  923. RECUR_USER_OPTIONS->cost_schedule = recur_user_cost_schedule;
  924. .in 0
  925. .NH 3
  926. USER_REANNEAL_FUNCTION=FALSE
  927. .XS
  928. \*(SN             USER_REANNEAL_FUNCTION=FALSE
  929. .XE
  930. .PP
  931. In asa.h, the macro
  932. .nf
  933. .in +3n
  934. #define \\
  935. .in +8n
  936. REANNEAL_FUNCTION(temperature, tangent, max_tangent) \\
  937. .in +3n
  938. (temperature * (max_tangent / tangent))
  939. .in 0
  940. .fi
  941. is used to determine the new temperature, subject to further tests in
  942. reanneal().  This is the default if USER_REANNEAL_FUNCTION is FALSE.
  943. .PP
  944. If the user sets the Pre-Compile DEFINE_OPTIONS USER_REANNEAL_FUNCTION
  945. to TRUE, then the function controlling the new reannealed temperature
  946. can be controlled, adaptively if desired using USER_OPTIONS, in user.c
  947. in user_reanneal(), and in recur_user_reanneal() if SELF_OPTIMIZE is
  948. TRUE.  The names of these functions are set to the relevant pointer in
  949. user.c, and can be changed if desired, i.e.,
  950. .in +3n
  951. USER_OPTIONS->reanneal_function = user_reanneal;
  952. .br
  953. RECUR_USER_OPTIONS->reanneal_function = recur_user_reanneal;
  954. .in 0
  955. .NH 3
  956. ASA_SAMPLE=FALSE
  957. .XS
  958. \*(SN             ASA_SAMPLE=FALSE
  959. .XE
  960. .PP
  961. When ASA_SAMPLE is set to TRUE, data is collected by ASA during its
  962. global optimization process to importance-sample the user's variables.
  963. Five OPTIONS become available to monitor the sampling: n_accepted,
  964. bias_acceptance, *bias_generated, average_weights, and limit_weights.
  965. .PP
  966. If average_weights exceeds the user's choice of limit_weights, then the
  967. ASA_OUT file will contain additional detailed information, including
  968. temperatures and biases for each current parameter.  To facilitate
  969. extracting importance-sampled information from the file printed out by
  970. the asa module, all relevant lines start with :SAMPLE[ |:|#|+].
  971. .PP
  972. Many Monte Carlo sampling techniques require the user to guess an
  973. appropriately decreasing \*Qwindow\*U to sample the variable space.
  974. The fat tail of the ASA generating function, and the decreasing
  975. effective range of newly accepted points driven by exponentially
  976. decreasing temperature schedules, removes this arbitrary aspect of such
  977. sampling.
  978. .PP
  979. However, note that, albeit local optima are sampled, the efficiency of
  980. ASA optimization most often leads to poor sampling in regions whose
  981. cost function is far from the optimal point; many such points may be
  982. important contributions to algorithms like integrals.  Accordingly,
  983. ASA_SAMPLE likely is best used to explore new regions and new systems.
  984. .PP
  985. To increase the sampling rate and thereby to possibly increase the
  986. accuracy of this algorithm, use one or a combination of the various
  987. OPTIONS available for slowing down the annealing performed by ASA.
  988. .NH 3
  989. ASA_PARALLEL=FALSE
  990. .XS
  991. \*(SN             ASA_PARALLEL=FALSE
  992. .XE
  993. .PP
  994. When ASA_PARALLEL is set to TRUE, parallel blocks of generated states
  995. are calculated of number equal to the minimum of OPTIONS->gener_block
  996. and OPTIONS->gener_block_max.  For most systems with complex nonlinear
  997. cost functions that require the fat tail of the ASA distribution,
  998. leading to high generated to acceptance ratios, this is the most CPU
  999. intensive part of ASA that can benefit from parallelization.
  1000. .PP
  1001. The actual number calculated is determined by a moving average,
  1002. determined by OPTIONS->gener_mov_avr, of the previous numbers of
  1003. OPTIONS->gener_block of generated states required to find a new best
  1004. accepted state.  If and when OPTIONS->gener_mov_avr is set to 0, then
  1005. OPTIONS->gener_block is not changed thereafter.
  1006. .NH 2
  1007. Printing DEFINE_OPTIONS
  1008. .XS
  1009. \*(SN         Printing DEFINE_OPTIONS
  1010. .XE
  1011. .LP
  1012. .NH 3
  1013. ASA_PRINT=TRUE
  1014. .XS
  1015. \*(SN             ASA_PRINT=TRUE
  1016. .XE
  1017. .PP
  1018. Setting this to FALSE will suppress all printing within asa.
  1019. .if t \{\
  1020. .EQ
  1021. delim off
  1022. .EN
  1023. .\}
  1024. .NH 3
  1025. ASA_OUT=\\"asa_out\\"
  1026. .XS
  1027. \*(SN             ASA_OUT=\\"asa_out\\"
  1028. .XE
  1029. .PP
  1030. The name of the output file containing all printing from asa.  If you
  1031. wish to attach a process number use ASA_OUT=\\"asa_out_$$\\".  (Use
  1032. ASA_OUT=\\"asa_out_$$$$\\" if this is set in the Makefile.) If
  1033. ASA_OUT=\\"STDOUT\\" then ASA will print to stdout.
  1034. .NH 3
  1035. USER_ASA_OUT=FALSE
  1036. .XS
  1037. \*(SN             USER_ASA_OUT=FALSE
  1038. .XE
  1039. .PP
  1040. When USER_ASA_OUT is set to TRUE, an additional Program Option pointer,
  1041. *asa_out_file, is used to dynamically set the name(s) of the file(s)
  1042. printed out by the asa module.  (This overrides any ASA_OUT settings.)
  1043. In user.c, if USER_OPTIONS->asa_out_file = "STDOUT";, then ASA will
  1044. print to stdout.
  1045. .PP
  1046. In one ASA_TEMPLATE provided (see the set of DEFINE_OPTIONS used in the
  1047. Makefile), USER_ASA_OUT is used to generate multiple files of separate
  1048. ASA runs.  (If USER_OPTIONS->QUENCH_PARAMETERS and/or
  1049. USER_OPTIONS->QUENCH_COST is set to TRUE in user.c, then this
  1050. ASA_TEMPLATE will separate runs with different quenching values.)
  1051. .NH 3
  1052. ASA_PRINT_INTERMED=TRUE
  1053. .XS
  1054. \*(SN             ASA_PRINT_INTERMED=TRUE
  1055. .XE
  1056. .PP
  1057. This option is only effective if ASA_PRINT is TRUE.  Setting
  1058. ASA_PRINT_INTERMED to FALSE will suppress much intermediate printing
  1059. within asa, especially arrays which can be large when the number of
  1060. parameters is large.  Printing at intermediate stages of
  1061. testing/reannealing has been turned off when SELF_OPTIMIZE is set to
  1062. TRUE, since there likely can be quite a bit of data generated; this can
  1063. be changed by explicitly setting ASA_PRINT_INTERMED to TRUE in the
  1064. Makefile or on your compilation command lines.
  1065. .NH 3
  1066. ASA_PRINT_MORE=FALSE
  1067. .XS
  1068. \*(SN             ASA_PRINT_MORE=FALSE
  1069. .XE
  1070. .PP
  1071. Setting ASA_PRINT_MORE to TRUE will print out more intermediate
  1072. information, e.g., new parameters whenever a new minimum is reported.
  1073. As is the case whenever tangents are not calculated by choosing some
  1074. ASA options, normally the intermediate values of tangents will not be
  1075. up to date.
  1076. .KS
  1077. .NH 2
  1078. Program OPTIONS
  1079. .XS
  1080. \*(SN         Program OPTIONS
  1081. .XE
  1082. .nf
  1083. .in +3n
  1084. typedef struct {
  1085. .in 0
  1086. .in +10n
  1087. LONG_INT LIMIT_ACCEPTANCES;
  1088. LONG_INT LIMIT_GENERATED;
  1089. int LIMIT_INVALID_GENERATED_STATES;
  1090. double ACCEPTED_TO_GENERATED_RATIO;
  1091. .sp 
  1092. double COST_PRECISION;
  1093. int MAXIMUM_COST_REPEAT;
  1094. int NUMBER_COST_SAMPLES;
  1095. double TEMPERATURE_RATIO_SCALE;
  1096. double COST_PARAMETER_SCALE;
  1097. double TEMPERATURE_ANNEAL_SCALE;
  1098. int USER_INITIAL_COST_TEMP;
  1099. double *user_cost_temperature;
  1100. .sp 
  1101. int INCLUDE_INTEGER_PARAMETERS;
  1102. int USER_INITIAL_PARAMETERS;
  1103. ALLOC_INT SEQUENTIAL_PARAMETERS;
  1104. double INITIAL_PARAMETER_TEMPERATURE;
  1105. int RATIO_TEMPERATURE_SCALES;
  1106. double *user_temperature_ratio;
  1107. int USER_INITIAL_PARAMETERS_TEMPS;
  1108. double *user_parameter_temperature;
  1109. .sp 
  1110. int TESTING_FREQUENCY_MODULUS;
  1111. int ACTIVATE_REANNEAL;
  1112. double REANNEAL_RESCALE;
  1113. LONG_INT MAXIMUM_REANNEAL_INDEX;
  1114. .sp 
  1115. double DELTA_X;
  1116. int DELTA_PARAMETERS;
  1117. double *user_delta_parameter;
  1118. int USER_TANGENTS;
  1119. int CURVATURE_0;
  1120. .sp
  1121. int QUENCH_PARAMETERS;
  1122. double *user_quench_param_scale;
  1123. int QUENCH_COST;
  1124. double *user_quench_cost_scale;
  1125. .sp
  1126. .in 0
  1127. #if OPTIONAL_DATA
  1128. .in 0
  1129. .in +10n
  1130. double *asa_data;
  1131. .in 0
  1132. #endif
  1133. #if USER_ASA_OUT
  1134. .in +10n
  1135. char *asa_out_file;
  1136. .in 0
  1137. #endif
  1138. #if USER_COST_SCHEDULE
  1139. .in +10n
  1140. double (*cost_schedule) ();
  1141. .in 0
  1142. #endif
  1143. #if USER_REANNEAL_FUNCTION
  1144. .in +10n
  1145. double (*reanneal_function) ();
  1146. .in 0
  1147. #endif
  1148. #if ASA_SAMPLE
  1149. .in +10n
  1150. int n_accepted;
  1151. double bias_acceptance;
  1152. double *bias_generated;
  1153. double average_weights;
  1154. double limit_weights;
  1155. .in 0
  1156. #endif
  1157. #if ASA_PARALLEL
  1158. .in +10n
  1159. int gener_mov_avr;
  1160. LONG_INT gener_block;
  1161. LONG_INT gener_block_max;
  1162. .in 0
  1163. #endif
  1164. .in +3n
  1165. }
  1166. .in 0
  1167. USER_DEFINES;
  1168. .KE
  1169. .PP
  1170. Note that two ways are maintained for passing the Program Options.
  1171. Check the comments in the NOTES file.  It may be necessary to change
  1172. some of the options for some systems.  Read the NOTES file for some
  1173. ongoing discussions and suggestions on how to try to optimally set
  1174. these options.  Note the distinction between trying to speed up
  1175. annealing/quenching versus trying to slow down annealing (which
  1176. sometimes can speed up the search by avoiding spending too much time in
  1177. some local optimal regions).  Templates are set up in ASA to
  1178. accommodate all alternatives.  Below, the defaults are given in square
  1179. brackets [].
  1180. .IP (A)
  1181. user module.
  1182. .br
  1183. When using ASA as part of a large library, it likely is easiest to make
  1184. these changes within the user module, e.g., using the template placed
  1185. in user.c.  The Program Options are stored in the structure
  1186. USER_DEFINES *OPTIONS (named USER_DEFINES *USER_OPTIONS in the user
  1187. module).
  1188. .IP (B)
  1189. asa module.
  1190. .br
  1191. It likely is most efficient to use a separate data file in the asa
  1192. module, avoiding repeated compilations of the code, to test various
  1193. combinations of Program Options, e.g., using the file asa_opt when
  1194. OPTIONS_FILE=TRUE in the Makefile or on your compilation command
  1195. lines.
  1196. .NH 3
  1197. OPTIONS->LIMIT_ACCEPTANCES[10000]
  1198. .XS
  1199. \*(SN             OPTIONS->LIMIT_ACCEPTANCES[10000]
  1200. .XE
  1201. .PP
  1202. The maximum number of states accepted before quitting.  All the
  1203. templates in ASA have been set to use LIMIT_ACCEPTANCES=1000 to
  1204. illustrate the way these options can be changed.  If LIMIT_ACCEPTANCES
  1205. is set to 0, then no limit is observed.  This can be useful for some
  1206. systems that cannot handle large integers.  (To exit at a specific
  1207. number of generated points, see the discussion at
  1208. LIMIT_INVALID_GENERATED_STATES below.)
  1209. .NH 3
  1210. OPTIONS->LIMIT_GENERATED[99999]
  1211. .XS
  1212. \*(SN             OPTIONS->LIMIT_GENERATED[99999]
  1213. .XE
  1214. .PP
  1215. The maximum number of states generated before quitting.  If
  1216. LIMIT_GENERATED is set to 0, then no limit is observed.  This can be
  1217. useful for some systems that cannot handle large integers.  (To exit at
  1218. a specific number of generated points, see the discussion at
  1219. LIMIT_INVALID_GENERATED_STATES below.)
  1220. .NH 3
  1221. OPTIONS->LIMIT_INVALID_GENERATED_STATES[1000]
  1222. .XS
  1223. \*(SN             OPTIONS->LIMIT_INVALID_GENERATED_STATES[1000]
  1224. .XE
  1225. .PP
  1226. This sets limits of repetitive invalid generated states, e.g., when
  1227. using this method to include constraints.  This also can be useful to
  1228. quickly exit asa() if this is requested by your cost function:  Setting
  1229. the value of LIMIT_INVALID_GENERATED_STATES to 0 will exit at the next
  1230. calculation of the cost function (possibly after a few more exiting
  1231. calls to calculate tangents and curvatures).  For example, to exit
  1232. asa() at a specific number of generated points, set up a counter in
  1233. your cost function, e.g., similar to the one in the test function in
  1234. user.c.  For all calls >= the limit of the number of calls to the cost
  1235. function, terminate by setting
  1236. USER_OPTIONS->LIMIT_INVALID_GENERATED_STATES = 0 and setting *cost_exit
  1237. = FALSE.  (Note that the number of calls counted will include those
  1238. calls used to set up some initializations.)
  1239. .NH 3
  1240. OPTIONS->ACCEPTED_TO_GENERATED_RATIO[1.0E-6]
  1241. .XS
  1242. \*(SN             OPTIONS->ACCEPTED_TO_GENERATED_RATIO[1.0E-6]
  1243. .XE
  1244. .PP
  1245. The least ratio of accepted to generated states.  If this value is
  1246. encountered, then the usual tests, including possible reannealing, are
  1247. initiated even if the timing does not coincide with the set
  1248. TESTING_FREQUENCY_MODULUS (defined below).  All the templates in ASA
  1249. have been set to use ACCEPTED_TO_GENERATED_RATIO=1.0E-4 to illustrate
  1250. the way these options can be changed.
  1251. .NH 3
  1252. OPTIONS->COST_PRECISION[1.0E-18]
  1253. .XS
  1254. \*(SN             OPTIONS->COST_PRECISION[1.0E-18]
  1255. .XE
  1256. .PP
  1257. This sets the precision required of the cost function if exiting
  1258. because of reaching MAXIMUM_COST_REPEAT.
  1259. .NH 3
  1260. OPTIONS->MAXIMUM_COST_REPEAT[5]
  1261. .XS
  1262. \*(SN             OPTIONS->MAXIMUM_COST_REPEAT[5]
  1263. .XE
  1264. .PP
  1265. The maximum number of times that the cost function repeats itself
  1266. before quitting.
  1267. .NH 3
  1268. OPTIONS->NUMBER_COST_SAMPLES[5]
  1269. .XS
  1270. \*(SN             OPTIONS->NUMBER_COST_SAMPLES[5]
  1271. .XE
  1272. .PP
  1273. The number of cost function values sampled to determine the initial
  1274. cost function temperature.
  1275. .NH 3
  1276. OPTIONS->TEMPERATURE_RATIO_SCALE[1.0E-5]
  1277. .XS
  1278. \*(SN             OPTIONS->TEMPERATURE_RATIO_SCALE[1.0E-5]
  1279. .XE
  1280. .PP
  1281. This scale is a guide to the expected cost temperature of convergence
  1282. within a small range of the global minimum.  As explained in the ASA
  1283. papers, and as outlined in the NOTES, this is used to set the rates of
  1284. annealing.  Here is a brief description in terms of the temperature
  1285. schedule outlined above.
  1286. .\"        Equations set only in PostScript\(rg ([g]troff)
  1287. .if t \{\
  1288. .EQ
  1289. delim $$
  1290. gsize 11
  1291. .EN
  1292. .\}
  1293. .PP
  1294. As a useful physical guide, the temperature is further parameterized in
  1295. terms of quantities
  1296. .if t $m sub i$ and $n sub i$,
  1297. .if n m_i and n_i,
  1298. derived from an \*Qexpected\*U final temperature (which is not enforced
  1299. in ASA),
  1300. .if t $T sub fi$,
  1301. .if n T_fi,
  1302. .ie t \{\
  1303. .EQ I
  1304. T sub fi = T sub 0i exp ( - m sub i ) ~
  1305. roman when ~ k sub fi = exp n sub i ~,
  1306. .EN
  1307. .\}
  1308. .el \{\
  1309. .in +8n
  1310. T_fi = T_0i exp(-m_i) when k_fi = exp(n_i),
  1311. .in 0
  1312. .\}
  1313. .ie t \{\
  1314. .EQ I
  1315. c sub i = m sub i exp ( - n sub i / D ) ~.
  1316. .EN
  1317. .\}
  1318. .el \{\
  1319. .in +8n
  1320. c_i = m_i exp(-n_i/D).
  1321. .in 0
  1322. .\}
  1323. However, note that since the initial temperatures and generating
  1324. indices,
  1325. .if t $T sub 0i$ and $k sub i$,
  1326. .if n T_0i and k_i,
  1327. are independently scaled for each parameter, it usually is reasonable
  1328. to simply take
  1329. .if t $"{" c sub i , ~ m sub i , ~ n sub i "}"$
  1330. .if n {c_i, m_i, n_i}
  1331. to be independent of the index
  1332. .if t $i$,
  1333. .if n i,
  1334. i.e., to be
  1335. .if t $"{" c , ~ m , ~ n "}"$ for all $i$.
  1336. .if n {c, m, n} for all i.
  1337. .PP
  1338. In asa.c,
  1339. .ie t \{\
  1340. .EQ I
  1341. m = - log ( roman TEMPERATURE_RATIO_SCALE ) ~.
  1342. .EN
  1343. .\}
  1344. .el \{\
  1345. .in +8n
  1346. m = -log(TEMPERATURE_RATIO_SCALE).
  1347. .in 0
  1348. .\}
  1349. This can be overridden if RATIO_TEMPERATURE_SCALES (further discussed
  1350. below) is set to TRUE, and then values of multipliers of
  1351. .if t $- log ( roman TEMPERATURE_RATIO_SCALE )$
  1352. .if n -log(TEMPERATURE_RATIO_SCALE)
  1353. are used in asa.c.  These multipliers are calculated in the user module
  1354. as USER_OPTIONS->user_temperature_ratio[] (and passed to
  1355. OPTIONS->user_temperature_ratio[] in the asa module).  Then,
  1356. .ie t \{\
  1357. .EQ I
  1358. m sub i = m ^ roman {OPTIONS->user_temperature_ratio[i]} ~.
  1359. .EN
  1360. .\}
  1361. .el \{\
  1362. .in +8n
  1363. m_i = m OPTIONS->user_temperature_ratio[i].
  1364. .in 0
  1365. .\}
  1366. .PP
  1367. For large numbers of parameters, TEMPERATURE_RATIO_SCALE is a very
  1368. influential Program Option in determining the scale of parameter
  1369. annealing.  It likely would be best to start with a larger value than
  1370. the default, to slow down the annealing.
  1371. .NH 3
  1372. OPTIONS->COST_PARAMETER_SCALE[1.0]
  1373. .XS
  1374. \*(SN             OPTIONS->COST_PARAMETER_SCALE[1.0]
  1375. .XE
  1376. .PP
  1377. This is the ratio of cost:parameter temperature annealing scales.  As
  1378. explained in the ASA papers, and as outlined in the NOTES, this is used
  1379. to set the rates of annealing.
  1380. .PP
  1381. In terms of the algebraic development given above for the
  1382. TEMPERATURE_RATIO_SCALE, in asa.c,
  1383. .ie t \{\
  1384. .EQ I
  1385. c sub {roman cost} = c ^ roman COST_PARAMETER_SCALE ~.
  1386. .EN
  1387. .\}
  1388. .el \{\
  1389. .in +8n
  1390. c_cost = c COST_PARAMETER_SCALE.
  1391. .in 0
  1392. .\}
  1393. .\"        Equations set only in PostScript\(rg ([g]troff)
  1394. .PP
  1395. COST_PARAMETER_SCALE is a very influential Program Option in
  1396. determining the scale of annealing of the cost function.
  1397. .NH 3
  1398. OPTIONS->TEMPERATURE_ANNEAL_SCALE[100.0]
  1399. .XS
  1400. \*(SN             OPTIONS->TEMPERATURE_ANNEAL_SCALE[100.0]
  1401. .XE
  1402. .PP
  1403. This scale is a guide to achieve the expected cost temperature sought
  1404. by TEMPERATURE_RATIO_SCALE within the limits expected by
  1405. LIMIT_ACCEPTANCES.  As explained in the ASA papers, and as outlined in
  1406. the NOTES, this is used to set the rates of annealing.
  1407. .PP
  1408. In terms of the algebraic development given above for the
  1409. TEMPERATURE_RATIO_SCALE, in asa.c,
  1410. .ie t \{\
  1411. .EQ I
  1412. n = log ( roman TEMPERATURE_ANNEAL_SCALE )~.
  1413. .EN
  1414. .\}
  1415. .el \{\
  1416. .in +8n
  1417. n = log(TEMPERATURE_ANNEAL_SCALE).
  1418. .in 0
  1419. .\}
  1420. .PP
  1421. For large numbers of parameters, TEMPERATURE_ANNEAL_SCALE probably
  1422. should at least initially be set to values greater than
  1423. *number_parameters, although it will not be as influential as
  1424. TEMPERATURE_RATIO_SCALE.
  1425. .NH 3
  1426. OPTIONS->USER_INITIAL_COST_TEMP[FALSE]
  1427. .XS
  1428. \*(SN             OPTIONS->USER_INITIAL_COST_TEMP[FALSE]
  1429. .XE
  1430. .PP
  1431. Setting USER_INITIAL_COST_TEMP to TRUE permits you to specify the
  1432. initial cost temperature.  This can be useful in problems where you
  1433. want to start the search at a specific scale.
  1434. .NH 3
  1435. OPTIONS->user_cost_temperature
  1436. .XS
  1437. \*(SN             OPTIONS->user_cost_temperature
  1438. .XE
  1439. .PP
  1440. If USER_INITIAL_COST_TEMP is TRUE, a pointer,
  1441. OPTIONS->user_cost_temperature, is used to adaptively initialize
  1442. parameters temperatures.  If this choice is elected, then
  1443. user_cost_temperature[] must be initialized (named
  1444. USER_OPTIONS->user_cost_temperature[] in the user module).  (If
  1445. USER_INITIAL_COST_TEMP is FALSE, then the pointer
  1446. *user_cost_temperature must be included in *OPTIONS, but it need not be
  1447. initialized.)
  1448. .NH 3
  1449. OPTIONS->INCLUDE_INTEGER_PARAMETERS[FALSE]
  1450. .XS
  1451. \*(SN             OPTIONS->INCLUDE_INTEGER_PARAMETERS[FALSE]
  1452. .XE
  1453. .PP
  1454. Include integer parameters in derivative and reannealing calculations.
  1455. This is useful when the parameters can be analytically continued
  1456. between their integer values, or if you set the parameter increments to
  1457. integral values by setting the DELTA_PARAMETERS option to TRUE, as
  1458. discussed further below.
  1459. .NH 3
  1460. OPTIONS->USER_INITIAL_PARAMETERS[FALSE]
  1461. .XS
  1462. \*(SN             OPTIONS->USER_INITIAL_PARAMETERS[FALSE]
  1463. .XE
  1464. .PP
  1465. ASA always requests that the user guess initial values of starting
  1466. parameters, since that guess is as good as any random guess the code
  1467. might make.  The default is to use the ASA distribution about this
  1468. point to generate an initial state of parameters and value of the cost
  1469. function that satisfy the user's constraints.  If
  1470. USER_INITIAL_PARAMETERS is set to TRUE, then the first user's guess is
  1471. used to calculate this first state.
  1472. .NH 3
  1473. OPTIONS->SEQUENTIAL_PARAMETERS[-1]
  1474. .XS
  1475. \*(SN             OPTIONS->SEQUENTIAL_PARAMETERS[-1]
  1476. .XE
  1477. .PP
  1478. The ASA default for generating new points in parameter space is to find
  1479. a new point in the full space, rather than to sample the space one
  1480. parameter at a time as do most other algorithms.  This is in accord
  1481. with the general philosophy of sampling the space without any prior
  1482. knowledge of ordering of the parameters.  However, if you have reason
  1483. to believe that at some stage(s) of search there might be some benefit
  1484. to sampling the parameters sequentially, then set SEQUENTIAL_PARAMETERS
  1485. to the parameter number you wish to start your annealing cycle, i.e.,
  1486. ranging from 0 to (*parameter_dimension - 1).  Then, ASA will cycle
  1487. through your parameters in the order you have placed them in all arrays
  1488. defining their properties, keeping track of which parameter is actively
  1489. being modified in OPTIONS->SEQUENTIAL_PARAMETERS, thereby permitting
  1490. adaptive changes.  Any negative value for SEQUENTIAL_PARAMETERS will
  1491. use the default ASA algorithm.  Upon exiting asa(),
  1492. SEQUENTIAL_PARAMETERS is reset back to its initial value.
  1493. .NH 3
  1494. OPTIONS->INITIAL_PARAMETER_TEMPERATURE[1.0]
  1495. .XS
  1496. \*(SN             OPTIONS->INITIAL_PARAMETER_TEMPERATURE[1.0]
  1497. .XE
  1498. .PP
  1499. The initial temperature for all parameters.  This is overridden by use
  1500. of the  USER_INITIAL_PARAMETERS_TEMPS option.
  1501. .NH 3
  1502. OPTIONS->RATIO_TEMPERATURE_SCALES[FALSE]
  1503. .XS
  1504. \*(SN             OPTIONS->RATIO_TEMPERATURE_SCALES[FALSE]
  1505. .XE
  1506. .PP
  1507. Different rates of parameter annealing can be set with
  1508. RATIO_TEMPERATURE_SCALES set to TRUE.  This requires initializing an
  1509. array in the user module as discussed below.
  1510. .NH 3
  1511. OPTIONS->user_temperature_ratio
  1512. .XS
  1513. \*(SN             OPTIONS->user_temperature_ratio
  1514. .XE
  1515. .PP
  1516. If RATIO_TEMPERATURE_SCALES is TRUE, a pointer,
  1517. OPTIONS->user_temperature_ratio, is used to adaptively set ratios of
  1518. scales used to anneal the parameters in the cost function.  This can be
  1519. useful when some parameters are not being reannealed, or when setting
  1520. the initial temperatures (using USER_INITIAL_PARAMETERS_TEMPS set to
  1521. TRUE) is not sufficient to handle all your parameters properly.  This
  1522. typically is not encountered, so it is advised to look elsewhere at
  1523. first to improve your search.  If this choice is elected, then
  1524. user_temperature_ratio[] must be initialized (named
  1525. USER_OPTIONS->user_temperature_ratio[] in the user module).  (If
  1526. RATIO_TEMPERATURE_SCALES is FALSE, then the pointer
  1527. *user_temperature_ratio must be included in *OPTIONS, but it need not
  1528. be initialized.)
  1529. .NH 3
  1530. OPTIONS->USER_INITIAL_PARAMETERS_TEMPS[FALSE]
  1531. .XS
  1532. \*(SN             OPTIONS->USER_INITIAL_PARAMETERS_TEMPS[FALSE]
  1533. .XE
  1534. .PP
  1535. Setting USER_INITIAL_PARAMETERS_TEMPS to TRUE permits you to specify
  1536. the initial parameter temperatures.  This can be useful in constrained
  1537. problems, where greater efficiency can be achieved in focussing the
  1538. search than might be permitted just by setting upper and lower bounds.
  1539. .NH 3
  1540. OPTIONS->user_parameter_temperature
  1541. .XS
  1542. \*(SN             OPTIONS->user_parameter_temperature
  1543. .XE
  1544. .PP
  1545. If USER_INITIAL_PARAMETERS_TEMPS is TRUE, a pointer,
  1546. OPTIONS->user_parameter_temperature, is used to adaptively initialize
  1547. parameters temperatures.  If this choice is elected, then
  1548. user_parameter_temperature[] must be initialized (named
  1549. USER_OPTIONS->user_parameter_temperature[] in the user module).  (If
  1550. USER_INITIAL_PARAMETERS_TEMPS is FALSE, then the pointer
  1551. *user_parameter_temperature must be included in *OPTIONS, but it need
  1552. not be initialized.)
  1553. .NH 3
  1554. OPTIONS->TESTING_FREQUENCY_MODULUS[100]
  1555. .XS
  1556. \*(SN             OPTIONS->TESTING_FREQUENCY_MODULUS[100]
  1557. .XE
  1558. .PP
  1559. The frequency of testing for periodic testing and reannealing.
  1560. .NH 3
  1561. OPTIONS->ACTIVATE_REANNEAL[TRUE]
  1562. .XS
  1563. \*(SN             OPTIONS->ACTIVATE_REANNEAL[TRUE]
  1564. .XE
  1565. .PP
  1566. This permits reannealing to be part of the fitting process.  This might
  1567. have to be set to FALSE for systems with very large numbers of
  1568. parameters just to decrease the number of function calls.
  1569. .NH 3
  1570. OPTIONS->REANNEAL_RESCALE[10.0]
  1571. .XS
  1572. \*(SN             OPTIONS->REANNEAL_RESCALE[10.0]
  1573. .XE
  1574. .PP
  1575. The reannealing scale used when MAXIMUM_REANNEAL_INDEX is exceeded.
  1576. .NH 3
  1577. OPTIONS->MAXIMUM_REANNEAL_INDEX[50000]
  1578. .XS
  1579. \*(SN             OPTIONS->MAXIMUM_REANNEAL_INDEX[50000]
  1580. .XE
  1581. .PP
  1582. The maximum index (number of steps) at which the initial temperature
  1583. and the index of the temperature are rescaled to avoid losing machine
  1584. precision.  ASA typically is quite insensitive to the value used due to
  1585. the dual rescaling.
  1586. .NH 3
  1587. OPTIONS->DELTA_X[0.001]
  1588. .XS
  1589. \*(SN             OPTIONS->DELTA_X[0.001]
  1590. .XE
  1591. .PP
  1592. The fractional increment of parameters used to take numerical
  1593. derivatives when calculating tangents for reannealing.  This is
  1594. overridden when DELTA_PARAMETERS is set to TRUE, as discussed further
  1595. below.
  1596. .PP
  1597. Note that this can cause evaluations of your cost function outside a
  1598. range when a parameter being sampled is at the boundary.  However, only
  1599. values of parameters within the ranges set by the user are actually
  1600. used for acceptance tests.
  1601. .NH 3
  1602. OPTIONS->DELTA_PARAMETERS[FALSE]
  1603. .XS
  1604. \*(SN             OPTIONS->DELTA_PARAMETERS[FALSE]
  1605. .XE
  1606. .PP
  1607. Different increments, used during reannealing to set each parameter's
  1608. numerical derivatives, can be set with DELTA_PARAMETERS set to TRUE.
  1609. This requires initializing an array in the user module as discussed
  1610. below.
  1611. .NH 3
  1612. OPTIONS->user_delta_parameter
  1613. .XS
  1614. \*(SN             OPTIONS->user_delta_parameter
  1615. .XE
  1616. .PP
  1617. If DELTA_PARAMETERS is TRUE, a pointer, OPTIONS->user_delta_parameter,
  1618. is used to adaptively set increments of parameters used to take
  1619. pseudo-derivatives (numerical derivatives).  For example, this can be
  1620. useful to reanneal integer parameters when a choice is made to permit
  1621. their derivatives to be taken.  If this choice is elected, then
  1622. OPTIONS->user_delta_parameter[] must be initialized (named
  1623. USER_OPTIONS->user_delta_parameter[] in the user module).  (If
  1624. DELTA_PARAMETERS is FALSE, then the pointer *user_delta_parameter must
  1625. be included in *OPTIONS, but it need not be initialized.)
  1626. .NH 3
  1627. OPTIONS->USER_TANGENTS[FALSE]
  1628. .XS
  1629. \*(SN             OPTIONS->USER_TANGENTS[FALSE]
  1630. .XE
  1631. .PP
  1632. By default, asa() calculates numerical tangents (first derivatives) of
  1633. the cost function for use in reannealing and to provide this
  1634. information to the user.  However, if USER_TANGENTS is set to TRUE,
  1635. then when asa() requires tangents to be calculated, a value of
  1636. *valid_state_generated_flag (called *cost_flag in ASA_TEST in user.c)
  1637. of FALSE is set and the cost function is called.  The user is expected
  1638. to set up a test in the beginning of the cost function to sense this
  1639. value, and then calculate the tangents[] array (containing the
  1640. derivatives of the cost function, or whatever sensitivity measure is
  1641. desired to be used for reannealing) to be returned to asa().  An
  1642. example is provided with the ASA_TEMPLATE for ASA_SAMPLE.
  1643. .NH 3
  1644. OPTIONS->CURVATURE_0[FALSE]
  1645. .XS
  1646. \*(SN             OPTIONS->CURVATURE_0[FALSE]
  1647. .XE
  1648. .PP
  1649. If the curvature array is quite large for your system, and you really
  1650. do not use this information, you can set CURVATURE_0 to TRUE which just
  1651. requires a one-dimensional curvature[0] to be defined to pass to the
  1652. asa module (to avoid problems with some systems).  This is most useful,
  1653. and typically is necessary, when minimizing systems with large numbers
  1654. of parameters since the curvature array is of size number of parameters
  1655. squared.
  1656. .PP
  1657. If you wish to calculate the curvature array periodically, every
  1658. reannealing cycle determined by OPTIONS->TESTING_FREQUENCY_MODULUS,
  1659. then set OPTIONS->CURVATURE_0 to -1.
  1660. .NH 3
  1661. OPTIONS->QUENCH_PARAMETERS[FALSE]
  1662. .XS
  1663. \*(SN             OPTIONS->QUENCH_PARAMETERS[FALSE]
  1664. .XE
  1665. .PP
  1666. This Program Option permits you to alter the basic algorithm to perform
  1667. selective \*Qquenching,\*U i.e., faster temperature cooling than
  1668. permitted by the ASA algorithm.  This can be very useful, e.g., to
  1669. quench the system down to some region of interest, and then to perform
  1670. proper annealing for the rest of the run.  However, note that once you
  1671. decide to quench rather than to truly anneal, there no longer is any
  1672. statistical guarantee of finding a global optimum.  Furthermore, once
  1673. you decide to quench there are many more alternative algorithms you
  1674. might wish to choose for your system.
  1675. .PP
  1676. Setting QUENCH_PARAMETERS to TRUE can be extremely useful in very large
  1677. parameter dimensions.  As discussed in the first 1989 VFSR paper, the
  1678. heuristic statistical proof of finding the global optimum reduces to
  1679. the following: The parameter temperature schedules must suffice to
  1680. insure that the product of individual generating distributions,
  1681. .ie t \{\
  1682. .EQ I
  1683.  g  = prod from i g sup i ~,
  1684. .EN
  1685. .\}
  1686. .el \{\
  1687. .in +8n
  1688. g = PROD_i g^i,
  1689. .in 0
  1690. .\}
  1691. taken at all annealing times, indexed by
  1692. .if t $k$,
  1693. .if n k,
  1694. of not generating a global optimum, given infinite time, is such that
  1695. .ie t \{\
  1696. .EQ I
  1697. prod from k ^ ( 1 - g sub k ) = 0 ~,
  1698. .EN
  1699. .\}
  1700. .el \{\
  1701. .in +8n
  1702. PROD_k (1-g_k) = 0,
  1703. .in 0
  1704. .\}
  1705. which is equivalent to
  1706. .ie t \{\
  1707. .EQ I
  1708. sum from k g sub k = inf ~.
  1709. .EN
  1710. .\}
  1711. .el \{\
  1712. .in +8n
  1713. SUM_k g_k = infinity.
  1714. .in 0
  1715. .\}
  1716. For the ASA temperature schedule, this is satisfied as
  1717. .ie t \{\
  1718. .EQ I
  1719. sum from k prod to D  1 / k sup -1/D = sum from k 1 / k = inf ~.
  1720. .EN
  1721. .\}
  1722. .el \{\
  1723. .in +8n
  1724. SUM_k PROD^D 1/k^(1/D) = SUM_k 1/k = infinity.
  1725. .in 0
  1726. .\}
  1727. Now, if the temperature schedule above is redefined as
  1728. .ie t \{\
  1729. .EQ I
  1730. T sub i ( k sub i ) = T sub 0i exp ( - c sub i k sub i sup Q/D ) ~,
  1731. .EN
  1732. .\}
  1733. .el \{\
  1734. .in +8n
  1735. T_i(k_i) = T_0i exp(-c_i k_i^(Q/D)),
  1736. .in 0
  1737. .\}
  1738. .ie t \{\
  1739. .EQ I
  1740. c sub i = m sub i exp ( - n sub i Q / D ) ~,
  1741. .EN
  1742. .\}
  1743. .el \{\
  1744. .in +8n
  1745. c_i = m_i exp(-n_i Q/D),
  1746. .in 0
  1747. .\}
  1748. in terms of the \*Qquenching factor\*U
  1749. .if t $Q$,
  1750. .if n Q,
  1751. then the above proof fails if
  1752. .if t $Q > 1$
  1753. .if n Q > 1
  1754. as
  1755. .ie t \{\
  1756. .EQ I
  1757. sum from k prod to D 1 / k sup -Q/D = sum from k 1 / k sup Q < inf ~.
  1758. .EN
  1759. .\}
  1760. .el \{\
  1761. .in +8n
  1762. SUM_k PROD^D 1/k^(Q/D) = SUM_k 1/k^Q < infinity
  1763. .in 0
  1764. .\}
  1765. .PP
  1766. This simple calculation shows how the \*Qcurse of dimensionality\*U
  1767. arises, and also gives a possible way of living with this disease which
  1768. will be present in any algorithm that substantially samples the
  1769. parameter space.  In ASA, the influence of large dimensions becomes
  1770. clearly focussed on the exponential of the power of
  1771. .if t $k$
  1772. .if n k
  1773. being
  1774. .if t $1/D$,
  1775. .if n 1/D,
  1776. as the annealing required to properly sample the space becomes
  1777. prohibitively slow.  So, if we cannot commit resources to properly
  1778. sample the space ergodically, then for some systems perhaps the next
  1779. best procedure would be to turn on quenching, whereby
  1780. .if t $Q$
  1781. .if n Q
  1782. can become on the order of the size of number of dimensions.  In some
  1783. cases tried, a small system of only a few parameters can be used to
  1784. determine some reasonable Program Options, and then these can be used
  1785. for a much larger space scaled up to many parameters.  This can work in
  1786. some cases because of the independence of dimension of the generating
  1787. functions.
  1788. .NH 3
  1789. OPTIONS->user_quench_param_scale
  1790. .XS
  1791. \*(SN             OPTIONS->user_quench_param_scale
  1792. .XE
  1793. .PP
  1794. If QUENCH_PARAMETERS is TRUE, a pointer,
  1795. OPTIONS->user_quench_param_scale, is used to adaptively set the scale
  1796. of the temperature schedule.  If this choice is elected, then
  1797. OPTIONS->user_quench_param_scale[] must be initialized (named
  1798. USER_OPTIONS->user_quench_param_scale[] in the user module), and values
  1799. defined for each dimension.  (If QUENCH_PARAMETERS is FALSE, then the
  1800. pointer *user_quench_param_scale must be included in *OPTIONS, but it
  1801. need not be initialized.)  The default in the asa module is to assign
  1802. the annealing value of 1 to all elements that might be defined
  1803. otherwise.  If values are selected greater than 1 using this Program
  1804. Option, then quenching is enforced.
  1805. .NH 3
  1806. OPTIONS->QUENCH_COST[FALSE]
  1807. .XS
  1808. \*(SN             OPTIONS->QUENCH_COST[FALSE]
  1809. .XE
  1810. .PP
  1811. If QUENCH_COST is set to TRUE, the scale of the power of
  1812. .if t $1/D$
  1813. .if n 1/D
  1814. temperature schedule used for the acceptance function can be altered in
  1815. a similar fashion to that described above when QUENCH_PARAMETERS is set
  1816. to TRUE.  However, note that this OPTION does not affect the annealing
  1817. proof of ASA, and so this may used without damaging the statistical
  1818. ergodicity of the algorithm.  Even greater functional changes can be
  1819. made using the Pre-Compile DEFINE_OPTIONS USER_COST_SCHEDULE.
  1820. .NH 3
  1821. OPTIONS->user_quench_cost_scale
  1822. .XS
  1823. \*(SN             OPTIONS->user_quench_cost_scale
  1824. .XE
  1825. .PP
  1826. If QUENCH_COST is TRUE, a pointer, OPTIONS->user_quench_cost_scale, is
  1827. used to adaptively set the scale of the temperature schedule.  If this
  1828. choice is elected, then OPTIONS->user_quench_cost_scale[0] must be
  1829. initialized (named USER_OPTIONS->user_quench_cost_scale[0] in the user
  1830. module).  (If QUENCH_COST is FALSE, then the pointer
  1831. *user_quench_cost_scale must be included in *OPTIONS, but it need not
  1832. be initialized.)  The default in the asa module is to assign the
  1833. annealing value of 1 to this element that might be defined otherwise.
  1834. .PP
  1835. OPTIONS->user_quench_cost_scale may be changed adaptively without
  1836. affecting the ergodicity of the algorithm, within reason of course.
  1837. This might be useful for some systems that require different approaches
  1838. to the cost function in different ranges of its parameters.  Note that
  1839. increasing this parameter beyond its default of 1.0 can result in
  1840. rapidly locking in the search to a small region of the cost function,
  1841. severely handicapping the algorithm.  On the contrary, you may find
  1842. that slowing the cost temperature schedule, by setting this parameter
  1843. to a value less than 1.0, may work better for your system.
  1844. .NH 3
  1845. OPTIONS->asa_data
  1846. .XS
  1847. \*(SN             OPTIONS->asa_data
  1848. .XE
  1849. .PP
  1850. If the Pre-Compile Option OPTIONAL_DATA[FALSE] is set to TRUE, an
  1851. additional Program Option pointer, OPTIONS->asa_data, becomes available
  1852. to to return additional information to the user module from the asa
  1853. module.  This information communicates with the asa module, and memory
  1854. must be allocated for it in the user module.  An example is given in
  1855. user.c when SELF_OPTIMIZE is TRUE.
  1856. .NH 3
  1857. OPTIONS->asa_out_file
  1858. .XS
  1859. \*(SN             OPTIONS->asa_out_file
  1860. .XE
  1861. .PP
  1862. If you wish to have the printing from the asa module be sent to a file
  1863. determined dynamically from the user module, set the Pre-Compile
  1864. Printing Option USER_ASA_OUT[FALSE] to TRUE, and define the Program
  1865. Option *asa_out_file in the user module.  (This overrides any ASA_OUT
  1866. settings.)  An example of this use for multiple asa() runs is given in
  1867. the user module.
  1868. .NH 3
  1869. OPTIONS->cost_schedule
  1870. .XS
  1871. \*(SN             OPTIONS->cost_schedule
  1872. .XE
  1873. .PP
  1874. If USER_COST_SCHEDULE[FALSE] is set to TRUE, then (*cost_schedule) ()
  1875. is created as a pointer to the function user_cost_schedule() in user.c,
  1876. and to recur_user_cost_schedule() if SELF_OPTIMIZE is set to TRUE.
  1877. .NH 3
  1878. OPTIONS->reanneal_function
  1879. .XS
  1880. \*(SN             OPTIONS->reanneal_function
  1881. .XE
  1882. .PP
  1883. If USER_REANNEAL_FUNCTION[FALSE] is set to TRUE, then
  1884. (*reanneal_function) () is created as a pointer to the function
  1885. user_reanneal() in user.c, and to recur_user_reanneal() if
  1886. SELF_OPTIMIZE is set to TRUE.
  1887. .NH 3
  1888. OPTIONS->n_accepted
  1889. .XS
  1890. \*(SN             OPTIONS->n_accepted
  1891. .XE
  1892. .PP
  1893. If ASA_SAMPLE is set to TRUE, n_accepted contains the current number of
  1894. points saved by the acceptance criteria.  This can be used to monitor
  1895. the sampling.
  1896. .NH 3
  1897. OPTIONS->bias_acceptance
  1898. .XS
  1899. \*(SN             OPTIONS->bias_acceptance
  1900. .XE
  1901. .PP
  1902. If ASA_SAMPLE is TRUE, this is the bias of the current state from the
  1903. Boltzmann acceptance test described above.
  1904. .NH 3
  1905. OPTIONS->bias_generated
  1906. .XS
  1907. \*(SN             OPTIONS->bias_generated
  1908. .XE
  1909. .PP
  1910. If ASA_SAMPLE is TRUE, a pointer, OPTIONS->bias_generated, contains the
  1911. the biases of the current state from the generating distributions of
  1912. all active parameters, described above.  OPTIONS->bias_generated[] must
  1913. be initialized in the user module.
  1914. .NH 3
  1915. OPTIONS->average_weights
  1916. .XS
  1917. \*(SN             OPTIONS->average_weights
  1918. .XE
  1919. .PP
  1920. IF ASA_SAMPLE is TRUE, this is the average of the weight[] array
  1921. holding the products of the inverse asa generating distributions of all
  1922. active parameters.
  1923. .PP
  1924. For example, OPTIONS->n_accepted can be used to monitor changes in a
  1925. new saved point in the cost function, and when OPTIONS->average_weights
  1926. reaches a specified number (perhaps repeated several times), the cost
  1927. function could return an invalid flag from the cost function to
  1928. terminate the run.  When the average_weights is very small, then
  1929. additional sampled points likely will not substantially contribute more
  1930. information.
  1931. .NH 3
  1932. OPTIONS->limit_weights
  1933. .XS
  1934. \*(SN             OPTIONS->limit_weights
  1935. .XE
  1936. .PP
  1937. If ASA_SAMPLE is set to TRUE, limit_weights is a limit on the value of
  1938. the average of the weight[] array holding the inverse asa generating
  1939. distribution.  When this lower limit is crossed, asa will no longer
  1940. send sampling output to be printed out, although it still will be
  1941. calculated.  As the run progresses, this average will decrease until
  1942. contributions from further sampling become relatively unimportant.
  1943. .NH 3
  1944. OPTIONS->gener_mov_avr
  1945. .XS
  1946. \*(SN             OPTIONS->gener_mov_avr
  1947. .XE
  1948. .PP
  1949. If ASA_PARALLEL is set to TRUE, gener_mov_avr determines the window of
  1950. the moving average of sizes of parallel generated states required to
  1951. find new best accepted states.  A reasonable number for many problems
  1952. is 3.
  1953. .PP
  1954. If and when OPTIONS->gener_mov_avr is set to 0, then
  1955. OPTIONS->gener_block is not changed thereafter.
  1956. .NH 3
  1957. OPTIONS->gener_block_max
  1958. .XS
  1959. \*(SN             OPTIONS->gener_block
  1960. .XE
  1961. .PP
  1962. If ASA_PARALLEL is set to TRUE, gener_block is an initial block size of
  1963. parallel generated states to calculate to determine a new best accepted
  1964. state.
  1965. .NH 3
  1966. OPTIONS->gener_block_max
  1967. .XS
  1968. \*(SN             OPTIONS->gener_block_max
  1969. .XE
  1970. .PP
  1971. If ASA_PARALLEL is set to TRUE, gener_block_max is an initial maximum
  1972. block size of parallel generated states to calculate to determine a new
  1973. best accepted state.  This can be changed adaptively during the run.
  1974. .PP
  1975. This can be useful if your parallel code assigns new processors \*Qon
  1976. the fly,\*U to compensate for some cost functions being more CPU
  1977. intensive, e.g., due to boundary conditions, etc.  Then
  1978. OPTIONS->gener_block_max may be larger than the number of physical
  1979. processors, e.g., if OPTIONS->gener_block would call for such a size.
  1980. .NH 1
  1981. User Module
  1982. .XS
  1983. \*(SN     User Module
  1984. .XE
  1985. .PP
  1986. This module includes user.c, user.h, and asa_user.h.  You may wish to
  1987. combine them into one file, or you may wish to use the ASA module as
  1988. one component of a library required for a large project.
  1989. .NH 2
  1990. int main(int argc, char **argv) | int asa_main()
  1991. .XS
  1992. \*(SN         int main(int argc, char **argv) | int asa_main()
  1993. .XE
  1994. .PP
  1995. In main(), set up your initializations and calling statements to asa.
  1996. The files user.c and user.h provide a sample program, as well as a
  1997. sample cost function for your convenience.  If you do not intend to
  1998. pass parameters into main, then you can just declare it as main()
  1999. without the argc and argv arguments, deleting other references to argc
  2000. and argv.
  2001. .PP
  2002. If ASA_LIB is set to TRUE, then asa_main() is used as a function call
  2003. instead of main().
  2004. .PP
  2005. If SELF_OPTIMIZE is set to TRUE, then the first main()/asa_main() in
  2006. user.c is closed off, and a different main()/asa_main() procedure in
  2007. user.c is used.
  2008. .KS
  2009. .NH 2
  2010. void initialize_parameters(
  2011. .XS
  2012. \*(SN         void initialize_parameters(
  2013. .XE
  2014. .nf
  2015. .in +10n
  2016. double *cost_parameters,
  2017. double *parameter_lower_bound,
  2018. double *parameter_upper_bound,
  2019. double *cost_tangents,
  2020. double *cost_curvature,
  2021. ALLOC_INT *parameter_dimension,
  2022. int *parameter_int_real,
  2023. USER_DEFINES * USER_OPTIONS)
  2024. .in 0
  2025. .KE
  2026. .PP
  2027. Before calling asa, the user must allocate storage and initialize some
  2028. of the passed parameters.  A sample procedure is provided as a
  2029. template.  In this procedure the user should allocate storage for the
  2030. passed arrays and define the minimum and maximum values.  Below is
  2031. detailed all the parameters which must be initialized.  If your arrays
  2032. are of size 1, still use them as arrays as described in user.c.
  2033. Alternatively, if you define `int user_flag', then pass &user_flag.
  2034. .PP
  2035. As written above, these are the names used in the user module.  All
  2036. these parameters could be passed globally in the user module, e.g., by
  2037. defining them in user.h instead of in main() in user.c, but since the
  2038. asa module only passes local parameters to facilitate recursive use,
  2039. this approach is taken here as well.
  2040. .KS
  2041. .NH 2
  2042. void recur_initialize_parameters(
  2043. .XS
  2044. \*(SN         void recur_initialize_parameters(
  2045. .XE
  2046. .nf
  2047. .in +10n
  2048. double *recur_cost_parameters,
  2049. double *recur_parameter_lower_bound,
  2050. double *recur_parameter_upper_bound,
  2051. double *recur_cost_tangents,
  2052. double *recur_cost_curvature,
  2053. ALLOC_INT *recur_parameter_dimension,
  2054. int *recur_parameter_int_real,
  2055. USER_DEFINES * RECUR_USER_OPTIONS)
  2056. .in 0
  2057. .KE
  2058. .PP
  2059. This procedure is used only if SELF_OPTIMIZE is TRUE, and is
  2060. constructed similar to initialize_parameters().
  2061. .KS
  2062. .NH 2
  2063. double user_cost_function(
  2064. .XS
  2065. \*(SN         double user_cost_function(
  2066. .XE
  2067. .nf
  2068. .in +10n
  2069. double *x,
  2070. double *parameter_minimum,
  2071. double *parameter_maximum,
  2072. double *tangents,
  2073. double *curvature,
  2074. ALLOC_INT *number_parameters,
  2075. int *parameter_type,
  2076. int *valid_state_generated_flag,
  2077. int *exit_status,
  2078. USER_DEFINES *OPTIONS)
  2079. .in 0
  2080. .KE
  2081. .LP
  2082. .NH 3
  2083. user_cost_function
  2084. .XS
  2085. \*(SN             user_cost_function
  2086. .XE
  2087. .PP
  2088. You can give any name to user_cost_function as long as you pass this
  2089. name to asa; it is called cost_function in the user module.  This
  2090. function returns a real value which ASA will minimize.  In cases where
  2091. it seems that the ASA default parameters are not very efficient for
  2092. your system, you might consider modifying the cost function being
  2093. optimized.  For example, if your actual cost function is of the form of
  2094. an exponential to an exponential, you might do better using the
  2095. logarithm of this as user_cost_function.
  2096. .NH 3
  2097. *x
  2098. .XS
  2099. \*(SN             *x
  2100. .XE
  2101. .PP
  2102. x (called cost_parameters in the user module) is an array of doubles
  2103. representing a set of parameters to evaluate.
  2104. .NH 3
  2105. double *parameter_minimum
  2106. .XS
  2107. \*(SN             double *parameter_minimum
  2108. .XE
  2109. .LP
  2110. .NH 3
  2111. double *parameter_maximum
  2112. .XS
  2113. \*(SN             double *parameter_maximum
  2114. .XE
  2115. .PP
  2116. These two arrays of doubles are passed.  Since ASA works only on
  2117. bounded search spaces, these arrays should contain the minimum and
  2118. maximum values each parameter can attain.  If you aren't sure, try a
  2119. factor of 10 or 100 times any reasonable values.  The exponential
  2120. temperature annealing schedule should quickly sharpen the search down
  2121. to the most important region.
  2122. .PP
  2123. Passing the parameter bounds in the cost function permits some
  2124. additional adaptive features during the search.  For example, setting
  2125. the lower bound equal to the upper bound will remove a parameter from
  2126. consideration.  In the user module these bounds are named
  2127. parameter_lower_bound and parameter_upper_bound.
  2128. .NH 3
  2129. double *tangents
  2130. .XS
  2131. \*(SN             double *tangents
  2132. .XE
  2133. .PP
  2134. This array of doubles is passed.  On return from asa this contains the
  2135. first derivatives of the cost function with respect to its parameters.
  2136. These can be useful for determining the value of your fit.  In this
  2137. implementation of ASA, the tangents are used to determine the relative
  2138. reannealing among parameters.
  2139. .NH 3
  2140. double *curvature
  2141. .XS
  2142. \*(SN             double *curvature
  2143. .XE
  2144. .PP
  2145. This array of doubles is passed next.  On return from asa, for real
  2146. parameters, this contains the second derivatives of the cost function
  2147. with respect to its parameters.  These also can be useful for
  2148. determining the value of your fit.
  2149. .PP
  2150. When the DEFINE_OPTIONS CURVATURE_0 option is set to TRUE the curvature
  2151. calculations are bypassed.  This can be useful for very large spaces.
  2152. .NH 3
  2153. ALLOC_INT *number_parameters
  2154. .XS
  2155. \*(SN             ALLOC_INT *number_parameters
  2156. .XE
  2157. .PP
  2158. An integer containing the dimensionality of the state space is passed
  2159. next (called parameter_dimension in the user module).  (If you define
  2160. `ALLOC_INT number_parameters', pass &number_parameters.) The arrays x
  2161. (representing cost_parameters), parameter_lower_bound,
  2162. parameter_upper_bound, cost_tangents, and parameter_int_real (below)
  2163. are to be of the size *number_parameters.  The array curvature which
  2164. may be of size the square of *number_parameters.
  2165. .NH 3
  2166. int *parameter_type
  2167. .XS
  2168. \*(SN             int *parameter_type
  2169. .XE
  2170. .PP
  2171. This integer array is passed next (passed as parameter_int_real in the
  2172. user module).  Each element of this array (each flag) can be:
  2173. REAL_TYPE (-1) (indicating the parameter is a real value), INTEGER_TYPE
  2174. (1) (indicating the parameter can take on only integer values),
  2175. REAL_NO_REANNEAL (-2), or INTEGER_NO_REANNEAL (2).  The latter two
  2176. choices signify that no derivatives are to be taken with respect to
  2177. these parameters.  For example, this can be useful to exclude
  2178. discontinuous functions from being reannealed.
  2179. .NH 3
  2180. *valid_state_generated_flag
  2181. .XS
  2182. \*(SN             *valid_state_generated_flag
  2183. .XE
  2184. .PP
  2185. valid_state_generated_flag is the address of an integer, named
  2186. cost_flag in the user module.  In user_cost_function(), *cost_flag
  2187. should be set to FALSE (0) if the parameters violate a set of user
  2188. defined constraints (e.g., as defined by a set of boundary conditions)
  2189. or TRUE (1) if the parameters represent a valid state.  If *cost_flag
  2190. is returned to asa() as FALSE, no acceptance test will be attempted,
  2191. and a new set of trial parameters will be generated.
  2192. .PP
  2193. If another algorithm suggests a way of incorporating constraints into
  2194. the cost function, then this modified cost function can be used as well
  2195. by ASA, or that algorithm might best be used a front-end to ASA.
  2196. .PP
  2197. If OPTIONS->USER_TANGENTS[FALSE] has been set to TRUE, then asa()
  2198. expects the user to test the value of *valid_state_generated_flag that
  2199. enters from asa().  If *valid_state_generated_flag enters with a value
  2200. of FALSE, then the user is expected to calculate the tangents[] array
  2201. (called cost_tangents[] in ASA_TEST in user.c) before exiting that
  2202. particular evaluation of the cost function.  An example is provided
  2203. with the ASA_TEMPLATE for ASA_SAMPLE.
  2204. .NH 3
  2205. int *exit_status
  2206. .XS
  2207. \*(SN             int *exit_status
  2208. .XE
  2209. .PP
  2210. The address of this integer is passed to asa.  On return it contains
  2211. the code for the reason asa exited.
  2212. .KS
  2213. .QS
  2214. .LP
  2215. NORMAL_EXIT = 0.  Given the criteria set largely by the DEFINE_OPTIONS,
  2216. the search has run its normal course.
  2217. .LP
  2218. P_TEMP_TOO_SMALL = 1.  A parameter temperature was too small using the
  2219. set criteria.  Often this is an acceptable status code.  You can omit
  2220. this test by setting NO_PARAM_TEMP_TEST to TRUE as one of your
  2221. Pre-Compile Options; then values of the parameter temperatures less
  2222. than EPS_DOUBLE are set to EPS_DOUBLE.
  2223. .LP
  2224. C_TEMP_TOO_SMALL = 2.  The cost temperature was too small using the set
  2225. criteria.  Often this is an acceptable status code.  You can omit this
  2226. test by setting NO_COST_TEMP_TEST to TRUE as one of your Pre-Compile
  2227. Options; then a value of the cost temperature less than EPS_DOUBLE is
  2228. set to EPS_DOUBLE.
  2229. .LP
  2230. COST_REPEATING = 3.  The cost function value repeated a number of times
  2231. using the set criteria.  Often this is an acceptable status code.
  2232. .LP
  2233. TOO_MANY_INVALID_STATES = 4.  Too many repetitive generated states were
  2234. invalid using the set criteria.  This is helpful when using *cost_flag,
  2235. as discussed above, to include constraints.
  2236. .QE
  2237. .KE
  2238. .PP
  2239. An exit code of 9, defined by exit(9), has been set in case any of the
  2240. calloc memory allocations fails.  Note that just relying on such a
  2241. simple summary given by *exit_status can be extremely deceptive,
  2242. especially in highly nonlinear problems.  It is \f2strongly\f1
  2243. suggested that the user set ASA_PRINT=TRUE before any production runs.
  2244. An examination of some periodic output of ASA can be essential to its
  2245. proper use.
  2246. .NH 3
  2247. USER_DEFINES *OPTIONS
  2248. .XS
  2249. \*(SN             USER_DEFINES *OPTIONS
  2250. .XE
  2251. .PP
  2252. All Program Options are defined in this structure.  Since Program
  2253. Options are passed to asa and the cost function, these may be changed
  2254. adaptively.
  2255. .PP
  2256. The Program Options also can be read in from a separate data file,
  2257. asa_opt, permitting efficient tuning/debugging of these parameters
  2258. without having to recompile the code.  This option has been added to
  2259. the asa module.
  2260. .KS
  2261. .NH 2
  2262. double recur_cost_function(
  2263. .XS
  2264. \*(SN         double recur_cost_function(
  2265. .XE
  2266. .nf
  2267. .in +10n
  2268. double *recur_cost_parameters,
  2269. double *recur_parameter_lower_bound,
  2270. double *recur_parameter_upper_bound,
  2271. double *recur_cost_tangents,
  2272. double *recur_cost_curvature,
  2273. int *recur_parameter_dimension,
  2274. int *recur_parameter_int_real,
  2275. int *recur_cost_flag,
  2276. int *recur_exit_code,
  2277. USER_DEFINES * RECUR_USER_OPTIONS)
  2278. .in 0
  2279. .KE
  2280. .PP
  2281. This procedure is used only if SELF_OPTIMIZE is TRUE, and is
  2282. constructed similar to cost_function().
  2283. .NH 2
  2284. double user_random_generator()
  2285. .XS
  2286. \*(SN         double user_random_generator()
  2287. .XE
  2288. .PP
  2289. A random number generator function must be selected.  It may be as
  2290. simple as one of the UNIX\(rg random number generators (e.g. drand48),
  2291. or may be user defined, but it should return a real value within [0,1)
  2292. and not take any parameters.  A good random number generator, randflt,
  2293. and its auxiliary routines are provided with the code in the user
  2294. module.
  2295. .NH 2
  2296. void initialize_rng()
  2297. .XS
  2298. \*(SN         void initialize_rng()
  2299. .XE
  2300. .PP
  2301. Most random number generators should be \*Qwarmed-up\*U by calling a
  2302. set of dummy random numbers.
  2303. .KS
  2304. .NH 2
  2305. double user_cost_schedule(
  2306. .XS
  2307. \*(SN         double user_cost_schedule(
  2308. .XE
  2309. .nf
  2310. .in +10
  2311. double test_temperature,
  2312. USER_DEFINES * USER_OPTIONS);
  2313. .in 0
  2314. .KE
  2315. .PP
  2316. If USER_COST_SCHEDULE[FALSE] is set to TRUE, then this function must
  2317. define how the new cost temperature is calculated during the acceptance
  2318. test.  The default is to return test_temperature.  For example, if you
  2319. sense that the search is spending too much time in local minima at some
  2320. stage of search, e.g., dependent on information gathered in
  2321. USER_OPTIONS, then you might return the square root of
  2322. test_temperature, or some other function, to slow down the sharpening
  2323. of the cost function acceptance test.
  2324. .KS
  2325. .NH 2
  2326. double recur_user_cost_schedule(
  2327. .XS
  2328. \*(SN         double recur_user_cost_schedule(
  2329. .XE
  2330. .nf
  2331. .in +10
  2332. double test_temperature,
  2333. USER_DEFINES * RECUR_USER_OPTIONS);
  2334. .in 0
  2335. .KE
  2336. .PP
  2337. If USER_COST_SCHEDULE[FALSE] and SELF_OPTIMIZE[FALSE] both are set to
  2338. TRUE, then this function must define how the new cost temperature is
  2339. calculated during the acceptance test.  As discussed above for
  2340. user_cost_schedule(), you may modify the default value of
  2341. test_temperature returned by this function, e.g., dependent on
  2342. information gathered in RECUR_USER_OPTIONS.
  2343. .KS
  2344. .NH 2
  2345. double user_reanneal(
  2346. .XS
  2347. \*(SN         double user_reanneal(
  2348. .XE
  2349. .nf
  2350. .in +10
  2351. double current_temp,
  2352. double tangent,
  2353. double max_tangent,
  2354. USER_DEFINES * USER_OPTIONS);
  2355. .in 0
  2356. .KE
  2357. .PP
  2358. If USER_REANNEAL_FUNCTION[FALSE] is set to TRUE, then this function
  2359. must define how the new temperature is calculated during reannealing.
  2360. .KS
  2361. .NH 2
  2362. double recur_user_reanneal(
  2363. .XS
  2364. \*(SN         double recur_user_reanneal(
  2365. .XE
  2366. .nf
  2367. .in +10
  2368. double current_temp,
  2369. double tangent,
  2370. double max_tangent,
  2371. USER_DEFINES * RECUR_USER_OPTIONS);
  2372. .in 0
  2373. .KE
  2374. .PP
  2375. If USER_REANNEAL_FUNCTION[FALSE] and SELF_OPTIMIZE[FALSE] both are set
  2376. to TRUE, then this function must define how the new temperature is
  2377. calculated during reannealing.
  2378. .KS
  2379. .NH 2
  2380. final_cost = asa(
  2381. .XS
  2382. \*(SN         final_cost = asa(
  2383. .XE
  2384. .nf
  2385. .in +10n
  2386. cost_function,
  2387. randflt,
  2388. cost_parameters,
  2389. parameter_lower_bound,
  2390. parameter_upper_bound,
  2391. cost_tangents,
  2392. cost_curvature,
  2393. parameter_dimension,
  2394. parameter_int_real,
  2395. cost_flag,
  2396. exit_code,
  2397. USER_OPTIONS);
  2398. .in 0
  2399. .KE
  2400. .PP
  2401. This is the form of the call to asa from user.c.  A double is returned
  2402. to the calling program as whatever it is named by the user, e.g.,
  2403. final_cost.  It will be the minimum cost value found by asa.
  2404. .KS
  2405. .NH 2
  2406. double asa(
  2407. .XS
  2408. \*(SN         double asa(
  2409. .XE
  2410. .nf
  2411. .in +10n
  2412. double (*user_cost_function) (
  2413. .in +5n
  2414. double *, double *, double *, double *, double *,
  2415. ALLOC_INT *, int *, int *, int *, USER_DEFINES *),
  2416. .in -5n
  2417. double (*user_random_generator) (void),
  2418. double *parameter_initial_final,
  2419. double *parameter_minimum,
  2420. double *parameter_maximum,
  2421. double *tangents,
  2422. double *curvature,
  2423. ALLOC_INT *number_parameters,
  2424. int *parameter_type,
  2425. int *valid_state_generated_flag,
  2426. int *exit_status,
  2427. USER_DEFINES * OPTIONS)
  2428. .in 0
  2429. .KE
  2430. .PP
  2431. This is how asa is defined in the ASA module, contained in asa.c and
  2432. asa_user.h.  All but the user_cost_function, user_random_generator, and
  2433. parameter_initial_final parameters have been described above as they
  2434. also are passed by user_cost_function().
  2435. .NH 3
  2436. double (*user_cost_function) ()
  2437. .XS
  2438. \*(SN             double (*user_cost_function) ()
  2439. .XE
  2440. .PP
  2441. The parameter (*user_cost_function*) () is a pointer to the cost
  2442. function that you defined in your user module.
  2443. .NH 3
  2444. double (*user_random_generator) ()
  2445. .XS
  2446. \*(SN             double (*user_random_generator) ()
  2447. .XE
  2448. .PP
  2449. A pointer to the random number generator function, defined in the
  2450. user module, must be passed next.
  2451. .NH 3
  2452. double *parameter_initial_final
  2453. .XS
  2454. \*(SN             double *parameter_initial_final
  2455. .XE
  2456. .PP
  2457. An array of doubles is passed (passed as cost_parameters in the user
  2458. module).  Initially, this array holds the set of starting parameters
  2459. which should satisfy any constraints or boundary conditions.  Upon
  2460. return from the asa procedure, the array will contain the best set of
  2461. parameters found by asa to minimize the user's cost function.
  2462. Experience shows that any guesses within the acceptable ranges should
  2463. suffice, since initially the system is at high annealing temperature
  2464. and ASA samples the breadth of the ranges.  The default is to have asa
  2465. generate a set of initial parameters satisfying the user's
  2466. constraints.  This can be overridden using
  2467. USER_INITIAL_PARAMETERS=TRUE, to have the user's initial guess be the
  2468. first generated set of parameters.
  2469. .NH 2
  2470. void print_time(char *message, FILE * ptr_out)
  2471. .XS
  2472. \*(SN         void print_time(char *message, FILE * ptr_out)
  2473. .XE
  2474. .PP
  2475. As a convenience, this subroutine and its auxiliary routine
  2476. aux_print_time are provided in asa.c to keep track of the time spent
  2477. during optimization.  Templates in the code are provided to use these
  2478. routines to print to output from both the asa and user modules.  These
  2479. routines can give some compilation problems on some platforms, and may
  2480. be bypassed using one of the DEFINE_OPTIONS.  It takes as its
  2481. parameters a string which will be printed and the pointer to file to
  2482. where the printout is directed.  An example is given in
  2483. user_cost_function to illustrate how print_time may be called
  2484. periodically every set number of calls by defining PRINT_FREQUENCY in
  2485. user.h.  See the NOTES file for changes in these routines that may be
  2486. required on some particular systems.
  2487. .NH 2
  2488. void sample(FILE * ptr_out, FILE * ptr_asa)
  2489. .XS
  2490. \*(SN         void sample(FILE * ptr_out, FILE * ptr_asa)
  2491. .XE
  2492. .PP
  2493. When ASA_TEMPLATE and ASA_SAMPLE are set to true, using data collected
  2494. in the ASA_OUT file, this routine illustrates how to extract the data
  2495. stored in the ASA_OUT file and print it to the user module.
  2496. .NH 1
  2497. Bug Reports
  2498. .XS
  2499. \*(SN     Bug Reports
  2500. .XE
  2501. .PP
  2502. I volunteer my time to make every reasonable effort to maintain only
  2503. current versions of the asa module, to permit the code to compile
  2504. without \*Qerror,\*U not necessarily without compiler \*Qwarnings.\*U
  2505. The user module is offered only as a guide to accessing the asa
  2506. module.  The NOTES file will contain updates for some standard
  2507. machines.  I welcome your bug reports and constructive critiques
  2508. regarding this code.  If you are having problems, it might help if you
  2509. enclose relevant portions your ASA_OUT file.
  2510. .PP
  2511. \*QFlames\*U will be rapidly quenched.
  2512. .if t \{\
  2513. .EQ
  2514. delim off
  2515. .EN
  2516. .\}
  2517. .KS
  2518. .\"         References
  2519. .[
  2520. $LIST$
  2521. .]
  2522. .KE
  2523. .pn 2
  2524. .bp
  2525. .af PN ii
  2526. .SH
  2527. .ce
  2528. Table of Contents
  2529. .LP
  2530. .PX no
  2531. .LP
  2532. .sp
  2533. $Id: readme.ms,v 4.2 1994/10/23 23:35:08 ingber Exp ingber $
  2534.